- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2016 04:21 AM
Looking to modify some work that has been done here to make the user experience a little better.
Firstly, on this record we want the user to be able to Save the record with no checks. If the user Submits, then we check for specific fields to be filled in.
The way it has been done via UI Actions works, but when the user submits there are no mandatory field markers and this is what needs addressing.
OK, create a client script and set the fields to be mandatory - easy ? yeah ? - Nope.
I have the following Client Script that checks for the action name, sets a boolean field marker to be true / false and then using an array, loop through all the fields that need checking. - the array has been truncated and some debugging added
function onSubmit() {
var action = g_form.getActionName();
g_form.addInfoMessage(action);
var bolMand = false;
if (action == 'submit_tpip')
bolMand = true;
var arrFields = ['u_project_manager','u_engineer'];
g_form.addInfoMessage(arrFields.length)
for (i=0;i<arrFields.length;i++)
{
g_form.addInfoMessage(arrFields[i] + ' : ' + i);
g_form.setMandatory(arrFields[i], bolMand);
if(i == arrFields.length-1)
g_form.addInfoMessage('Breaking');
}
when I click on save, I see this
which is fine
when I click on Submit, I see this......
So, Why does it do the first field correctly and get suck on the second ?
Why is it not even reaching the if statement to show the "Breaking" info message ?
It is not the field as it is happening on whatever subset of the array I am chosing, and in this screenshot I have just reversed the two fields from the previous code
Ontop of that, I did try using true instead of bolMand and it gives the same problem
Bizzarely, the following code works so it is clearly to do with this running in a loop
g_form.setMandatory('u_engineer',bolMand);
g_form.setMandatory('u_project_manager',bolMand);
g_form.addInfoMessage('and here I am');
any ideas or thoughts ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2016 09:20 AM
Hi Julian,
Could there possibly be a scoping issue with your variable 'i' you are using for your loop that may be causing the unexpected behavior?
You may try changing your for statement to:
for (var i=0;i<arrFields.length;i++)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2016 06:16 AM
Hi Julian,
I dont find anything wrong with the code.
I run this code on Fuji and Geneva, it worked for me.
What version you are running this code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2016 06:49 AM
Must have been a browser issue as I have rebooted over lunch and it is now OK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2016 07:00 AM
I would also suggest to add try catch statements in client side codes as well whenever doing something related to DOM manupulation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2016 07:07 AM
not sure if that would have helped on that particular one.
for quite a few options I do add a try / catch, but on those which is using the OOB code I am not quite some festidious