Copying variable values of RITM to a record Producer via UI Action

DPrasna
Tera Contributor

Hi All,

 

I have a requirement to create a button on RITM form that converts the current RITM to an Incident.

I am trying to redirect the UI action to a record producer as below

 

var ritmNumber = g_form.getValue('number');
        var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=62fb775337fasergfgtne012';
        window.open(url);
 
However I need help with copying the variable values for current RITM and set/populate it to the variable values of the record producer. How do I do it?
Need help on the same
 
 
15 REPLIES 15

@DPrasna 

your onload script seems wrong.

is that the complete script?

this link has working solution

Redirect from a UI Action to a Catalog Item and set default values 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ok but I do not have to check for any users so can i just leave if(user) and simply det values directly?

function onLoad() {
    var opened_by = getParmVal('sysparm_opened_by');
    var priority = getParmVal('sysparm_priority');
    var description = getParmVal('sysparm_description');
    var short_description = getParmVal('sysparm_short_description');
    var business_service = getParmVal('sysparm_business_service');

    g_form.setValue('opened_by', opened_by);
    g_form.setValue('priority', priority);
    g_form.setValue('short_description', short_description);
    g_form.setValue('description', description);
    g_form.setValue('business_service', business_service);

    function getParmVal(name) {

        var url = document.URL.parseQuery();

        if (url[name]) {

            return decodeURI(url[name]);

        } else {

            return;

        }

    }
}
 
UI Action

 

var priority = current.priority;
var opened_by = current.opened_by;
var short_description = current.short_description;
var description = current.description;
var business_service = current.business_service;



gs.setRedirect('com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=1248c78d37440f40f51ea6d2b3990e67&sysparm_opened_by=' + opened_by + '&sysparm_priority=' + priority + '&sysparm_description=' + description + '&sysparm_short_description=' + short_description + '&sysparm_business_service=' + business_service);

 

not working

 

@DPrasna 

in UI action you should use action object

var priority = current.priority;
var opened_by = current.opened_by;
var short_description = current.short_description;
var description = current.description;
var business_service = current.business_service;

action.setRedirectURL('com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=1248c78d37440f40f51ea6d2b3990e67&sysparm_opened_by=' + opened_by + '&sysparm_priority=' + priority + '&sysparm_description=' + description + '&sysparm_short_description=' + short_description + '&sysparm_business_service=' + business_service);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@DPrasna 

what debugging did you perform?

it went to catalog form?

what came in alert?

function onLoad() {
    var opened_by = getParmVal('sysparm_opened_by');
    var priority = getParmVal('sysparm_priority');
    var description = getParmVal('sysparm_description');
    var short_description = getParmVal('sysparm_short_description');
    var business_service = getParmVal('sysparm_business_service');

    g_form.setValue('opened_by', opened_by);
    g_form.setValue('priority', priority);
    g_form.setValue('short_description', short_description);
    g_form.setValue('description', description);
    g_form.setValue('business_service', business_service);

    function getParmVal(name) {

        var url = document.URL.parseQuery();
        alert(url); // what came here????

        if (url[name]) {

            return decodeURI(url[name]);

        } else {

            return;

        }

    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader