- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 03:59 AM - edited 10-15-2024 04:00 AM
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
Advance Thanks yours response
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 11:36 AM - edited 10-18-2024 11:37 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 11:16 AM
So in the log, for this RITM, you expect to exactly see
...project_name:test,
is_this_related_to_business_application_or_technical_service_1:business application, business_application:ec...
or something else? If it is this, maybe the space is throwing it off? Try changing the value to business_application or something without a space, and make sure there is not an errant space before or after the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 04:55 AM
no spaces given for the variable after and before. I am using correct value only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 06:15 AM
Does your Question Choice look like this for what you are testing, or do you have something else in the Value field?
Since the Script Include accessing the 'current' record is not pulling in the MRVS values correctly, if this can't be explained by the Value of your Question Choice then an alternative to try is to first query for the current record. This step should not be necessary, but stranger things have happened.
updateRitmValues: function(zertoRITM) {
var curGr = new GlideRecord('sc_req_item');
if (curGr.get(current.sys_id)) {
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;
var mrvs = curGr.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');
}
}
What do the 2 exact logs look like with this approach?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 11:48 AM
Hello,
It seems that you're encountering an issue with the Multi-row Variable Set (MRVS) where you're trying to pass the value from a parent RITM's MRVS variable to a child RITM variable, but instead of getting the expected value, you're seeing something like `com.glide.catalog.scripting.rhino.impl.GlideElementScriptingModel$2@5533d9de`.
This issue is usually related to how MRVS data is accessed in ServiceNow. When dealing with MRVS, you need to iterate over the rows and properly reference the individual fields within the MRVS.
Here's how you can fix it:
1. **Iterate through MRVS Rows**: MRVS is a set of rows, so you need to loop through the rows to access individual fields. Simply assigning `current.variables.MRVS.business_name` directly won't work.
Here's an example of how you can correctly pass the MRVS values from the parent RITM to the child RITM:
javascript
// Assuming MRVS has multiple rows, you need to iterate over them
var mrvRows = current.variables.MRVS; // Accessing MRVS from the current RITM
// Loop through MRVS rows and access the field
for (var i = 0; i < mrvRows.length; i++) {
var businessName = mrvRows[i].business_name; // Replace 'business_name' with the actual variable name in MRVS
// Assuming you want to set the child RITM variable with the same business name value
childRITM.variables.business_name = businessName;
// If you have multiple child RITMs or need specific ones, you can use GlideRecord to update them
// Example: var childRITM = new GlideRecord('sc_req_item'); etc.
}
```
2. **Check the Variable Name**: Ensure that `business_name` is the correct variable name in both the parent and child RITMs.
3. **Ensure Data Types Match**: Since both variables are of type **selectbox**, ensure that you're passing the correct value type and handling it correctly in the child RITM.
By iterating over the MRVS and accessing each row correctly, you should avoid the issue of getting a reference to an object like `GlideElementScriptingModel$2@5533d9de`.
If you still encounter issues, feel free to share more details, and I'd be happy to help further.
Best regards,
Raja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 05:00 AM
Thanks for the response, used as your instructions
1. i used first condition with given script logic, but it is not passing the value.
2I used the correct backend name value only
3.both variables type is selectbox and parent variable mrvs variable
all conditions applied and used still passing rhino error value 'com.glide.catalog.scripting.rhino.impl.GlideElementScriptingModel$2@5533d9de'