Hi All,
Hope everyone doing fine!
I have got a situation where I need to use java script only for making a prompt mandatory.So unless the user selects any value in the prompt, the reprompt button next to it and finish button in the page should be disabled.
If anyone could help me with this, I would be really grateful to them!.
Thanks in advance!
Honestly, I see little need for javascript here. If you make the prompt mandatory in Report Studio, any Finish or Next buttons will be automatically disabled until a selection is made. And all the Reprompt button does is reset the prompts, so why bother disabling it? Or just remove it altogether if you don't want the user to have that option.
Quote from: bdbits on 27 Aug 2014 10:54:56 AM
Honestly, I see little need for javascript here. If you make the prompt mandatory in Report Studio, any Finish or Next buttons will be automatically disabled until a selection is made. And all the Reprompt button does is reset the prompts, so why bother disabling it? Or just remove it altogether if you don't want the user to have that option.
Thanks for the reply bro.!
To make things simpler, I have just specified my requirement in that way. Even after trying different ways, I came to conclusion that by making a prompt mandatory using java scripting, My work is almost done.
Cheers!
Might surprise some people here, but I'm with bdbits on this one. If you can give us the entire picture, perhaps we will come up with a way to achieve what you need without scripting.
To make a prompt mandatory via scripting, you'll have to have a function running constantly, checking for the state of the prompt. It's a big overhead for a small mission.
I don't know how I missed this.
I actually wrote an article for PG2 that describes this, but it isn't up yet.
The documentation for the Prompt API doesn't actually include all of the features available to it. It might be because they're still working on the API (I've heard some rumors that they're implementing some new features in upcoming versions), so there's no guarantee that the hidden features will work in later versions. One of the undocumented features is a series of control properties that can be set with ["@propertyName"], such as ["@required"].
paulScripts.getControl(promptName)["@required"]=true;
paulScripts.getControl(promptName).checkData();
I used the properties feature in the past. It's nice. Useful to GET property values. However:
A. It's undocumented.
B. If I'm not mistaken (I might be) It's no different than actually setting the required property for the prompt, which doesn't require coding...
You can use JavaScript to toggle it, and the finish button will activate/deactivate as necessary. The thing that bugs me is that I can't find a decent way of disabling the prompt, as far as I can tell, the disabled flag is set when the page is loaded.
right, something like "this prompt is required only if that value is selected"? That's one scenario (Though I'd probably just go with altering the verification for the finish button).
re disabling, you can access the DOM object and disable that, couldn't you?
That's pretty much it, but I don't like it. This should work:
paulScripts.getControl(promptName).m_oSubmit.parentNode.disabled=true
But select and search prompts don't play well with the m_oSubmit. After searching it just doesn't work. The alternative is to add divs around the prompt, and that's just ugly.
ugly, but upgradable...