Need to use a script to write to fields in std_change_proposal

Imad Nacer2
Tera Contributor

I have a record producer for domain migration requests that I created on the std_change_proposal table. On the Standard Change Proposal form there is a tab called "Change Request values" that contains numerous questions (backout plan, test plan, etc). Its on the change_request table.

I want to use the script in my record producer to fill out these questions but i'm having trouble. For example, to test filling in the short description I tried:

 

var gr = new GlideRecord("std_change_record_producer");

gr.addEncodedQuery(query);
gr.query();

while (gr.next()){

gr.variables.short_description= 'Test';

}

 

But that didn't do it. Anyone have any suggestions on what I'm doing wrong?

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

In your attempt 'query' in the addEncodedQuery line is undefined.  The Change Request values field is on the std_change_proposal table, so you don't need to do a GlideRecord query in the producer script, rather just use the syntax current.field_name=value to set a field value.  This field (yes, the whole tab is one field) is a little different as one field holds every field and value to be applied in the template, so to populate it in the producer script you would do something like this:

current.setValue('template_value', 'short_description=Test^description=This is only a Test^implementation_plan=Here is what you need to do');

with as many ^field_name=... additions that you need.

Hello @Brad Bowman  ,

Can you please guide us "How to write a client script on the change request values"?
The reference qualifiers for the reference fields are not getting applied
so I have created before query BR to restrict ci's for Business service field.
this will apply if you click on magnifying glass
but users are still able to type the restricted ci's and select them manually.
someone suggested to write a client script and use Ajax,

If i try to retrieve the value, the entire template value is coming, so how can I retrieve single field value from the dropdown?
Please share your views here.