Have to Access variable value from RITM form through script include

Kumaran ava
Tera Contributor

Hi, i have a variable "license_number" on the catalog item to get the license number from the users.

in case if the user tries to create a second request using the same license number an error message should be shown

 

there is no license number field on the RITM form, however it is present on the variables section, i have to access variable values from the RITM record. 

 

also, if there is a pre existing RITM record with the same license number then the user should be provided with the RITM number in the error message, on clicking the RITM number the user should be navigated to the RITM record in portal, so i have to provide a link of the record on the error message. 

 

 

Kindly provide solutions if known, help in this matter would be much appreciated.

 

 

1 ACCEPTED SOLUTION

Vengadesh
Tera Guru

Hi @Kumaran ava , You can try the below logic:

1.Configure an onChange catalog client script on the field "License number" and pass the newValue as parameter to the script include

2.In script include query the RITM table, build an encoded query as like in the image:

Modify your catalog item name and variable name and pass the parameter value(i.e your "License number" value)

Vengadesh_1-1709205161339.png

3.Execute the query and return your Glide object

4.In client script , receive the response and use href and target method within addInfoMessage for RITM record navigation 

 

If the above logic helps with your question, mark my answer as accepted solution and mark as helpful

View solution in original post

4 REPLIES 4

piyushsain
Tera Guru
Tera Guru

hi @Kumaran ava ,

You can use this script in Before Insert BR

 

var gr = new GlideRecord('sc_req_item');
gr.addQuery('cat_item', 'ADD SYS ID of CATALOG ITEM');
gr.addActiveQuery();
gr.query();

while (gr.next()) {
    if (current.variables.license_number == gr.variables.license_number) {
        gs.addErrorMessage('Already available RITM for license ' + gr.number);
        current.setAbortAction(true);
    }

}

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

Thanks for the reply, i also have the requirement of providing link to the existing RITM in the client side so this cannot be done in the business rule 

Vengadesh
Tera Guru

Hi @Kumaran ava , You can try the below logic:

1.Configure an onChange catalog client script on the field "License number" and pass the newValue as parameter to the script include

2.In script include query the RITM table, build an encoded query as like in the image:

Modify your catalog item name and variable name and pass the parameter value(i.e your "License number" value)

Vengadesh_1-1709205161339.png

3.Execute the query and return your Glide object

4.In client script , receive the response and use href and target method within addInfoMessage for RITM record navigation 

 

If the above logic helps with your question, mark my answer as accepted solution and mark as helpful

Thank you @Vengadesh  for the solution.