Client Script for Error Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2017 08:05 AM
Hi I'm trying to write a client script to make an error message when the "Portfolio" field is changed to "AIT" and the choice field below it (A question about being submitted on behalf of a Business Partner) has not be answered already. This is the script I have so far, but it is not working. The commented out part I'm not sure if I need or not, I had it originally but was trying to see if it would work without it. Any ideas would be very appreciated!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//if (isLoading || newValue === '') {
// return;
//}
if(g_form.getValue('portfolio')=='AIT'
&& g_form.getValue('u_choice_1')==''){
g_form.addErrorMessage('Please answer "Business Partner" Question');
}
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2017 09:18 AM
Cool, try this...i feel we are almost there
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(g_form.DisplayBox('portfolio).value=='AIT' && g_form.getValue('u_choice_1')==''){
g_form.addErrorMessage('Please answer "Business Partner" Question');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2017 10:21 AM
For some reason it is giving me a ton of errors on this code. Trying to figure it out but if you can see any issues please let me know, I'm still a novice with JS. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2017 10:24 AM
Was just missing a ' so I fixed that so I'd run. However, when I went back to the form to try it out it gave me this error message under the field:
onChange script error: TypeError: g_form.DisplayBox is not a function function onChange_dmn_demand_portfolio_1(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } if(g_form.DisplayBox('portfolio').value =='AIT' && g_form.getValue('u_choice_1')==''){ g_form.addErrorMessage('Please answer "Business Partner" Question'); } }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2017 02:08 AM
Hi Aubrey,
This time i will be right
if (isLoading || newValue === '') {
return;
}
if(g_form.getDisplayBox('portfolio').value=='AIT' && g_form.getValue('u_choice_1')==''){
g_form.addErrorMessage('Please answer "Business Partner" Question');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2017 07:47 AM
Thank you very much, it did in fact work! Now I have another question. In the u_choice_1 field I need to create an alert if that field is answered with the "Yes" choice. I tried to replicate the client script for it using the one you gave me, but I cannot get it to work. Would you mind telling me what I'm doing wrong? Here it is below. Thank you!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Alert telling user to update portfolio based on the business partners business group/department
if(g_form.getDisplayBox('u_choice_1').value==1){
g_form.alert("Please update the Portfolio to represent the Business Partner's Business Group/Department");
}
}