Service catalog

Amit Kumar13
Tera Expert

I have to pass the form value from one catalog form to another.
Scenario:
I have opened one catalog form and there is one reference field.
Based on ref field I have to redirect this to new catalog form 

Now i have to populate previous form value to new form where on which we have redirected.

1 ACCEPTED SOLUTION

Amit Kumar13
Tera Expert

Thanks guyz for your support but i have my solution.

We can use url+&sysparm_field1=" "+&sysparm_field2=" "; to pass the value form one form to another form without submitting 1st form
on second form use onload script 

var val= getParameterValue('sysparm_field1');
var val= getParameterValue('sysparm_field1');





View solution in original post

3 REPLIES 3

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Amit Kumar13 

In your first catalog item (let's call it "Catalog Item A"), you need to capture the value from the reference field. You can use a Client Script for this

onSubmit Catalog Client Script

function onSubmit() {
  
    var referenceValue = g_form.getValue('reference_field_name');
    
    // Store it in a query parameter or use it to construct the URL for redirection
    var redirectURL = '/catalog.do?sys_id=' + g_form.getSysId() + '&reference_value=' + referenceValue;
    
    // Set the URL of the next catalog item form
    g_form.setRedirectURL(redirectURL);
    
    return true; 
}

 

When redirecting to the new catalog item (let's call it "Catalog Item B"), you'll need to handle the query parameters to pre-populate the fields in Catalog Item B.

onLoad Catalog Client Script 

function onLoad() {
    var queryParams = new URLSearchParams(window.location.search);
    var referenceValue = queryParams.get('reference_value');
    if (referenceValue) {
        g_form.setValue('field_in_catalog_item_b', referenceValue);
    }
}

 

Amit Kumar13
Tera Expert

Thanks guyz for your support but i have my solution.

We can use url+&sysparm_field1=" "+&sysparm_field2=" "; to pass the value form one form to another form without submitting 1st form
on second form use onload script 

var val= getParameterValue('sysparm_field1');
var val= getParameterValue('sysparm_field1');