Check for a field changing while in an onSubmit client script?

SC10
Kilo Guru

When a user clicks on a UI action to screen a Demand, the State of the Demand changes to "Screening".

Is there a way to have an onSubmit client script watch this change, and return false; (aborting the submit action?) with certain conditions (such as the "Assigned to" being blank).

This would essentially force a mandatory field to submit the form into a State of screen via UI action, without having to make the field normally mandatory (as this would prevent the user from simply updating the form's other fields and saving, due to the "Assigned to" being blank [aka the assigned to is still unknown, but I want the Demand to still be partially filled out and saved]).

Thank you

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi Shane,



In the UI Action itself you have a client callable provision. You need to check Client field & have below code used.



Action Name: valid_reason     ---in Action Name field


Onclick: specify_reason()           --in Onclick field



Code:


function specify_reason()


{


var chk_assigned_to=g_form.getValue('assigned_to');


if(chk_assigned_to=='')


{


alert('Kindly get assigned to filled in');


g_form.setMandatory('assigned_to,true);


} //this involves running on client side



The code that you have written for the server remains as is to update the state of demand to screening.



Thanks,


Jaspal Singh



Hit Like or Correct on the impact of response.


I was trying to avoid having to add in scripts to all of my UI actions on Demand... Defer, Screen, Approve, etc. Do you feel this is the best approach?


Off the bat, I think, onSubmit will execute every time a record is submitted. So, I don't think it's a good idea but then again, since you've said, there are other states as well, let me think for a bit, if that's okay.



I'll get back to you, Thank you so much for your response.



Darshak


Rama Chandra D
Kilo Guru

Hi Shane,



Yes, this is doable. I don't think you would need a client script. Look at the 'Close Task' UI action for the tasks with requested items, it does a similar action - set the state to close after ensuring mandatory fields are populated.



Darshak