how to populate catalog item form with values from notification

AnciaM
Tera Guru

I have a use case where , I need to trigger emails to user to request for new asset as their old asset is reaching end of life. So I have designed a scheduled flow to trigger notifications. This notification needs to have link to the catalog item, where the user can select for a different type of asset ,etc . I need to populate the old device details in the catalog form . I need to provide a link in notification. If user clicks on the link ,populate the old asset and its details in the catalog form.

2 ACCEPTED SOLUTIONS

yashkamde
Tera Guru

Hello @AnciaM ,

I would recommend you to use URL Parameters to Pre-populate like,
"https://<instance>.service-now.com/sc_cat_item.do?sys_id=<catalog_sys_id>&variable_name=value",

In your case you can use like this -> "https://dev12345.service-now.com/sc_cat_item.do?sys_id=abcd1234&old_asset_tag=ASSET001&old_model=Lap..."

and then in notification build a link to redirect 
"<a href="https://dev12345.service-now.com/sc_cat_item.do?sys_id=abcd1234&old_asset_tag=${asset.asset_tag}&old...}">Request Replacement Asset</a>"

If my response helped mark as helpful and accept the solution..

View solution in original post

Dinesh Chilaka
Giga Guru

Hi @AnciaM ,

In Your mail script wherever you are linking to catalog item just add extra param in that url as 

https://your_instance_id.service-now.com/esc?id=sc_cat_item&sys_id='sys_id_of_your_catalog_item'&asset_sys_id='your_old_asset_sys_id'

Use the following onLoad Catalog Client script to the parameter values from the URL

function onLoad() {
 
        var oldAssetSysId =getParameterValue('asset_sys_id');
 
        if (oldAssetSysId) {
           //write your GlideAjax Script Include to get the whatever values you want from tha old asset and set those values to    the current form using g_form.setValue()
        }
 
    function getParameterValue(name) {
        var url = top.location.href;
        var value = new URLSearchParams(url).get(name);
        if (value) {
            return value;
        }
    }
}

if my response helps, mark my response as helpful and accept the solution.

View solution in original post

4 REPLIES 4

yashkamde
Tera Guru

Hello @AnciaM ,

I would recommend you to use URL Parameters to Pre-populate like,
"https://<instance>.service-now.com/sc_cat_item.do?sys_id=<catalog_sys_id>&variable_name=value",

In your case you can use like this -> "https://dev12345.service-now.com/sc_cat_item.do?sys_id=abcd1234&old_asset_tag=ASSET001&old_model=Lap..."

and then in notification build a link to redirect 
"<a href="https://dev12345.service-now.com/sc_cat_item.do?sys_id=abcd1234&old_asset_tag=${asset.asset_tag}&old...}">Request Replacement Asset</a>"

If my response helped mark as helpful and accept the solution..

Singh Manish
Tera Contributor

Hello @AnciaM,

 

It looks like  you have already implemented the notification part.

For pre-populating the catalog item with the old asset details, you can achieve this by passing the asset information as URL parameters and parsing them using catalog client script. You may  refer to the below link for guidance on how to parse URL parameters in a client script: https://servicenowguru.com/client-scripts-scripting/parse-url-parameters-client-script/

 

Kindly Mark this as Helpful if it answers you question.

 

Thank you.

 

Dinesh Chilaka
Giga Guru

Hi @AnciaM ,

In Your mail script wherever you are linking to catalog item just add extra param in that url as 

https://your_instance_id.service-now.com/esc?id=sc_cat_item&sys_id='sys_id_of_your_catalog_item'&asset_sys_id='your_old_asset_sys_id'

Use the following onLoad Catalog Client script to the parameter values from the URL

function onLoad() {
 
        var oldAssetSysId =getParameterValue('asset_sys_id');
 
        if (oldAssetSysId) {
           //write your GlideAjax Script Include to get the whatever values you want from tha old asset and set those values to    the current form using g_form.setValue()
        }
 
    function getParameterValue(name) {
        var url = top.location.href;
        var value = new URLSearchParams(url).get(name);
        if (value) {
            return value;
        }
    }
}

if my response helps, mark my response as helpful and accept the solution.

Its_Azar
Kilo Sage

Hi there @AnciaM 

 

In the notification, build the catalog URL with query parameters (for example, the old asset sys_id or asset tag). On the catalog item, use an onLoad Catalog Client Script to read those parameters (g_request.getParameter()), look up the asset on the server (via GlideAjax or Flow action), and populate the relevant variables. 

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG