The CreatorCon Call for Content is officially open! Get started here.

How to autofill mrvs variable with signleline text

Ak8977
Tera Expert

In the catalog there are Q1 and Q2. Q1 is a yes/no type and Q2 is MRVS. 
 there are 3 variables in the MRVS.
 If I select "yes" in the Q1 then some default text "text123" need to be filled in the 3rd variable in the multi row variable set. Can anyone help me with the script for this.

thanks,

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Ak8977 

 

I am not 100% sure but thinking for low code, I might be wrong

 

Created UI policy 

On Q1 - if yes, then show Q3 and in that variable use the default value

LearnNGrowAtul_0-1706521541460.png

 

 

This can be a workaround. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hello @Dr Atul G- LNG ,
if I create one more question for that it won't required default value in that case it won't work. So if there is any script share it with me . It would be helpful for me

 

Amit Verma
Kilo Patron
Kilo Patron

Hi @Ak8977 

 

You can use g_service_catalog API to modify data within the MRVS based on the value of a field on the parent catalog item form. Refer the official documentation and give it a try :

https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/g_service_catalogClientAPI#...

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Manikmodi16
Tera Guru

Hi,

 

You can create an onLoad Catalog Client Script for the variable set such that it fetches the value from the catalog item variable and sets the value for the MRVS variable.

 

function onLoad() {
  if (g_service_catalog.parent.getValue("Q1") == "yes") {      //Replace Q1 with the backend name of the field
    g_form.setValue("mvrs_variable", "text123");  // Replace mvrs_variable with backend name of the field
  }
}

 

If you find this helpful, please marks this as the solution. Thanks!