Need to populate the values from another table

Manasa Allu
Tera Contributor

Hi Team,

I am creating the Standard change request through the Request item table using UI action (create Standard Change)

ManasaAllu_0-1713364491186.png

 

Once the user clicks the standard change menu, it goes to the catalog item form.

ManasaAllu_1-1713364491293.png

 

The user selects one item from the list, it goes to the change form.

 

We have one field called "Related Sr" in the change form.

 

ManasaAllu_2-1713364491193.png

 

We need to populate this field automatically with the request item number.

 

Regards,

Manasa.

 

6 REPLIES 6

Kristen Ankeny
Kilo Sage

If you look at some of the OOB "Create change" UI actions, you'll see they pass a sysparm_query that includes parent=sys_id_of_the_record. This ends up in the URL on the target change as "sysparm_link_parent" - you can parse the url to grab that parameter and use that to set the field.

Hi Kristen,

 

Thanks for the reply.

 

Could you please explain with details.

 

Regards,
manasa.

 

This is one option:

 

function onLoad() {
   var gUrl = getParameterValue('sysparm_link_parent');
   g_form.setValue('your_field_name', gUrl);
   
   function getParameterValue(name) {
        var url = top.location.href;
        var value = new URLSearchParams(url).get(name);
        if (value) {
            return value;
        }
        if (!value) {
            var gUrl = new GlideURL();
            gUrl.setFromCurrent();
            value = gUrl.getParam("view");
            return value; //this will give you the value
		}
   }
   
}

Hello Kristen,

We have tried the above solution, but it is not working in the reference field.

 

In the change form, I have created the string field (Service Request), which shows the system ID of the request.

ManasaAllu_0-1713879765537.png

 

Please help me on this.

 

Regards,

Manasa.