The CreatorCon Call for Content is officially open! Get started here.

Client Script to set value true if field from another is true

taddparris
Kilo Expert

Need help with a client script to set a field true, if a field on another table related to a change request is true.   Looking at the Affected CI's to see if Tagged for DR is true.  

What I need is:

If "u_tagged_dr" is true on the "task_ci" table and matches the sysid of the Change Request

Set value of field "u_core_or_critical_ci_affected" to true

Here is what I have so far and it is not working

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

               

      var cc = new GlideRecord('task_ci');

  cc.addQuery('task_ci', g_form.getValue('u_tagged_dr', true));

  cc.query();

                if (cc.next())   {

                      g_form.setValue('u_core_or_critical_ci_affected', 'true');

        }

}

Thanks,

11 REPLIES 11

Running it after won't work because the 'save' is already been done (that's why they are called after rules.)



Time to double check that query to ensure it does what you expect. I've always been a little adverse to using the addOrCondition(). I prefer to build encoded queries using the list filter. Check this video for an example:



Video: Scripting Complex Queries Quickly


If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you