javascript addQuery

phillipf1
Kilo Contributor

Need some guidance on how to write a query in a client script.

I want to query a reference table for a specific record and then pull other attributes from that record along and update the current record.

Hope it makes sense.

Thanks

Phillip

9 REPLIES 9

phillipf1
Kilo Contributor

Auto assignment based on the Support Group of the CI. I would like to get the CI "Support Group" and populate the "Assignment Group" field on an Incident with the value. I've seen a script to this effect but can't seem to find it anymore.


phillipf1
Kilo Contributor

Thanks Christopher, the script you provided works great. How do I align it with the whole "client script best practice" thing? I'm no developer so any help would be greatly appreciated.


This WIKI article should help you: http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#Run_Only_Necessary_Scripts


lbraff
Kilo Contributor

Hi Phillip,



Can you share the script you used to auto assign based on the support group of the CI?



Auto assignment based on the Support Group of the CI. I would like to get the CI "Support Group" and populate the "Assignment Group" field on an Incident with the value. I've seen a script to this effect but can't seem to find it anymore.



Thank you,


Laura


phillipf1
Kilo Contributor

Hi Laura



Used the following script as base:



//Set Assignment Group to CI's support group if assignment group is empty



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



    if (!isLoading) {


          if (newValue) {


                if
(newValue != oldValue) {


   
              if
(g_form.getValue('assignment_group' != '') {


                         
var ciSupportGroup = g_form.getReference('cmdb_ci').support_group;


                         
if (ciSupportGroup != '')


g_form.setValue('assignment_group', ciSupportGroup);      
            }


                }


          }


    }


}



Hope it helps.