Parent mrvs variable passing the value to child variable through script include, its not updating

servicenow pla1
Tera Expert

HI Community,

Need yours assistance please on below issue 

Parent RITM mrvs variable passing the value to child RITM variable through script include, its not updating actual value. Its updating "com.glide.catalog.scripting.rhino.impl.GlideElementScriptingModel$2@5533d9de" how to fix this.

 

parent MRVS variable type is selectbox and child variable type selectbox and using below script

ritm.variables.business_name = current.variables.MRVS.business_name;

Please find below screen shot and help

servicenowpla1_0-1728989932124.png

 

Advance Thanks yours response



1 ACCEPTED SOLUTION

Hi @Brad Bowman  @Omkar Mone @sadif_raja 

 

Thanks you all for your time and your suggestions, I have learned something new from your responses.

 

Finally I have done deep analysis on my code and find the issue and fixed.

 

Actually My requirement is

Parent RITM -> Child RITM->ChildRITM

 

1. Parent RITM variableset variable type is select box and child variable type is select box

2.Parent RITM variable have choice values

  1.business_service

  2.technical_service

3.child variable choice values different 

  1.business_app

   2.technical_services

 

Both variables choice values is different so I mapped used below script 

 

Var abName = current.variables.mrvs.variablename;

var is_business_app = ' ';

 

If(abName == 'parent choice value i.e business_service'){

is_business_app = 'child choice value i.e business_app';

}else if(abName == 'parent choice value i.e technical_service'){

is_business_app = 'child choice value i.e technical_services';

}

 

ChildRITM.variables.childvariableName = is_business_app;

 

Finally this code fixed the Issue, I hope this will helpfull others also.

 

Thanks to ServiceNow Community.

 

View solution in original post

21 REPLIES 21

This is a solution that will be specific to your environment.  Post your entire script using the insert code icon </> and we can work on troubleshooting with confirming names and values, adding logs if necessary.

testing

below line of code passing error value
ritm.variables.u_business_application_technical_service = current.variables.iti_isd_common_product.is_this_related_to_business_application_or_technical_service_1.getDisplayValue();

I used getValue() and getDisplayValue() both functions

The current.variables.mrvs_name.variable_name... approach won't work as there are multiple values in this JSON object.  I've added some temporary logging so you can confirm the MRVS is retrieved, and the value of your ridiculously-named MRVS variable.  If/once these are the expected values, you need to make sure the variable type on the RITM that you are copying to is the same type as the MRVS variable.

 

As noted in the script, I'm assuming the script is working up until the MRVS part and that the other RITM variables are populated correctly.  If not, we need to go back further to see which RITM is retrieved by the GlideRecord.  You can incorporate the budget_number and business_segment variable assignment from the MRVS variables in the same if block once the first one is working.

updateRitmValues: function(zertoRITM) {
        var ritm = new GlideRecord('sc_req_item');
        ritm.addQuery('sys_id', zertoRITM);
        ritm.query();
        if (ritm.next()) {
            ritm.variables.requested_for = current.variables.requested_for;
            ritm.variables.requested_by = current.variables.requested_by;
			ritm.variables.business_application = current.variables.business_application1;
            ritm.variables.application_service = current.variables.eapm_sql1;
            ritm.variables.u_dr_tier = current.variables.dr_tier;
			//assuming script is working to this point, above variables correctly populated
			var mrvs = current.variables.iti_isd_common_product;
			gs.info('PLA1 MRVS = ' + mrvs)
            var rowCount = mrvs.getRowCount();
            for (var i = 0; i < rowCount; i++) {
            	var row = mrvs.getRow(i);
				gs.info('PLA1 MRVS variable = ' + row.is_this_related_to_business_application_or_technical_service_1)
            	if (row.is_this_related_to_business_application_or_technical_service_1) {
            ritm.variables.u_business_application_technical_service = row.is_this_related_to_business_application_or_technical_service_1;
            	break;
            	}
            }

            //ritm.variables.u_business_application_technical_service = current.variables.iti_isd_common_product.is_this_related_to_business_application_or_technical_service_1.getDisplayValue();
            //ritm.variables.u_budget_number = current.variables.iti_isd_common_product.clarity_budget_number;
            //ritm.variables.u_business_segment = current.variables.iti_isd_common_product.business_segment;
            
            var newMRVS = ritm.variables.server_to_be_protected;
            var mrvsRow = newMRVS.addRow();

            mrvsRow.cpu_gb = current.variables.sql_cpu; // getValue('cpu');
            mrvsRow.memory_gb = current.variables.sql_memory;
            mrvsRow.disk_total_storage_for_each_server_in_gb = current.variables.disk_size.getDisplayValue();
            mrvsRow.server_ip = current.variables.sn_ip;
            //mrvsRow.server_name = current.variables.scs_server_build_information.sn_build_name;
            mrvsRow.server_type = '2'; //This is exclusively for APP server so Server Type on RITM is set to Sql.

            ritm.update();
            return ritm.getValue('number');
        }
    }

 

after used given function parent RITM values not updated on child RITM. but in LOG i captured MRVS values

Pln1 MRVS = clarity_budget_number:T1PRJ000000000000000000 IRx Analytics 9.2,business_segment:4d9243251bc6c6sys_ID,other_business_segment_not_listed:,department:3aa6d479db6c44dcsys_ID,on_premise_justification:,project_name:test,
is_this_related_to_business_application_or_technical_service_1:com.glide.catalog.scripting.rhino.impl.GlideElementScriptingModel$2@3b462dc0, business_application:ec01eb561b811cd03c3741sys_ID,technical_services_1:,eapm:eaa6b4a21bdc5050bd44sys_ID,components_application_services:undefined,downtime_window:,change_group_isd:7c5b063a1b1c105sys_ID,approval_group1:f5a3c59f1bca3810asys_ID,assignment_group:,support_group:7d344d3f1b21045sys_ID 

 

here also getting same error value returned (bold letters)