getting undefined while accessing multi row variable set variables in the email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 08:19 AM
I have one Multi row variable set in my catalog item and the same i wanna get in my approver email notification
1.but while accessing those values with toString() method i am getting "undefined"
2. and even for getDisplayvalue() also coming same
3. but when i accesing directly , it is priting sys_id's
if (gr.variables.move_for == 'group')
{
var mrvs_data_group = '';
var mrvs_group = gr.variables.group_move_mrvs; //replace with the internal name of your MRVS
var rowCount = mrvs_group.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row_group = mrvs_group.getRow(i);
mrvs_data_group += '\n----------' + '\n' +
'User: ' + row_group.user.name.toString() + '\n' +
'To Home Base: ' + row_group.to_home_base_bulk.name.toString() + '\n' +
'To Floor: ' + row_group.to_floor_bulk.name.toString() + '\n' +
'To Space: ' + row_group.to_space_bulk.name.toString() + '\n' +
'Date: ' + row_group.employee_requested_move_date + '\n' +
'From Home Base: ' + row_group.from_home_base.name.toString() + '\n' +
'From Floor: ' + row_group.from_floor.name.toString() + '\n' +
'From Space: ' + row_group.from_space.name.toString() + '\n' ;
}
template.print('Move Participants: ' + mrvs_data_group.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 09:52 AM
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.sysapproval);
gr.query();
if (gr.next()) {
template.print("Requestor: " + gr.request.requested_for.name + " (" + gr.request.requested_for.title + ")" + "\n");
template.print("Requestor's Location: " + gr.request.requested_for.location.getDisplayValue() + "\n");
if (gr.cat_item == '3ad9fe740a0a3ca1019dfb95f01b6d02') { // Sys_ID for "VPN Access"
template.print("VPN Recipient: " + gr.variables.vpn_name_of_person.getDisplayValue() + "\n");
template.print("Note - Recipient may differ from the requested for if the network account was not available at the time of the request.\n");
}
if (gr.cat_item == '363dd5f7132d72001c7851522244b010') { // Sys_ID for "Remote Network Access"
template.print("Access Recipient: " + gr.variables.requested_for.getDisplayValue() + "\n");
template.print("Note - Recipient may be different than the Requested for if the request was made on behalf of another user.\n");
}
template.print("\n");
var apprId = current.approver.sys_id.toString();
if (current.approver == apprId) {
var apv = new GlideRecord('sysapproval_approver');
apv.addQuery('sysapproval', current.sysapproval);
apv.addQuery('approver', '!=', apprId);
apv.addQuery('state', 'approved');
apv.query();
if (apv.hasNext()) {
template.print('Approved by:\n');
while (apv.next()) {
template.print(apv.approver.name + " (" + apv.approver.title + ")" + "\n");
}
template.print('\n');
}
}
var descItem;
if (gr.cat_item == 'd33f4c1e1dafe40038a023c3ac7c8123') { // Sys_ID for 'Other Hardware'
descItem = gr.variables.hw_other_description.toString();
} else if (gr.cat_item == 'a743942e0a0a3ca1002a8d852ad512d2') { // Sys_ID for 'Other Software'
descItem = gr.variables.other_software.toString();
} else if (gr.cat_item == 'a2174832130bc3001c7851522244b06b') { // Sys_ID for 'SAP BPC'
if (current.wf_activity == '3aa17968875d15104efd7488cebb3525') { //Workflow Activity is Primary BPC Approver
descItem = gr.cat_item.name.toString();
descItem += '\nBPC application: ' + gr.variables.application_request.getDisplayValue();
} else {
descItem = "Microsoft Office Suite Standard for SAP BPC";
}
} else if (gr.cat_item == 'd6bfd64f0f43234062b6e64be1050e12') { // Sys_ID for 'SkySite'
descItem = gr.cat_item.name.toString() + ' - ' + gr.variables.application_request.getDisplayValue();
} else {
descItem = gr.cat_item.name.toString();
}
if (descItem.substring(descItem.length - 1) === ".") {
descItem = descItem.substring(0, descItem.length - 1);
}
template.print("Item: " + descItem + "\n");
if (gr.cat_item == '5dfe4ee30a0a3ca10152ad18056df254') { //sys_ID for "Corrigo - New Access"
template.print('\nItem Description: \n' + gr.description + '\n');
}
if (gr.cat_item == '5dfe547d0a0a3ca100ffb12718da96d3') { //sys_ID for "Onesite / FAS - New Access Request"
template.print('\nItem Description: \n' + gr.description + '\n');
}
if (gr.cat_item == '9a055e0cdbbd00900d231e133996195e') { //sys_ID for "Google Groups" cat item
template.print('Requesting: ' + gr.variables.requesting.getDisplayValue() + '\n');
if (gr.variables.name_of_the_group) {
template.print('Group Name: ' + gr.variables.name_of_the_group.getDisplayValue() + '\n');
}
template.print('Email Address: ' + gr.variables.group_email.getDisplayValue() + '\n');
}
if (gr.cat_item == '7435b0421b2105108caa64e1604bcb7c') { //sys_ID for "SharePoint (Cloud) User Access" cat item
template.print('Application: ' + gr.variables.application.getDisplayValue() + '\n');
if (gr.variables.application != gs.getProperty('Fixed_Assets_System_cat_item')) { //'Fixed Assets System' cat item
template.print('Access Type: ' + gr.variables.access_type.getDisplayValue() + '\n');
}
}
if (gr.cat_item == '0ce11b281be0b4508caa64e1604bcb05') { //sys_ID for "Contingent/Agency Worker Virtual Machine" cat item
template.print('Requested for: ' + gr.variables.requested_for.getDisplayValue() + '\n');
template.print('Requesting: Local Admin on ' + gr.variables.cw_vm_option + ' virtual machine');
if (gr.variables.cw_vm_name != null) {
template.print(' ' + gr.variables.cw_vm_name.getDisplayValue() + '\n');
}
}
if (gr.cat_item == '2d4c5c2a1bfd6410eff0c8486b4bcbe2') { // Sys_ID for "Admin Rights for Computer" cat item
template.print('Device Name: ' + gr.variables.device_name.getDisplayValue() + '\n');
template.print('Duration: ' + gr.variables.duration.getDisplayValue() + '\n');
}
if (gr.cat_item == '2c3764e2dbb254109144f271399619e8') { // Sys_ID for "Docusign Additional Access" cat item
template.print('Access level: ' + gr.variables.access_type.getDisplayValue() + '\n');
}
if (gr.cat_item == '914bd48d13da13001c7851522244b064') { // Sys_ID for "Corrigo Hardware Request or Issue" cat item
template.print('Type of Request: ' + gr.variables.requested_service.getDisplayValue() + '\n');
template.print('Requested For: ' + gr.variables.requested_for.getDisplayValue() + '\n');
if (gr.variables.selected_asset) {
var assetGr = new GlideRecord('alm_hardware');
assetGr.get(gr.variables.selected_asset);
template.print('Previous Device: ' + assetGr.display_name + ' | ' + assetGr.serial_number + '\n');
}
}
if (gr.cat_item == '5ee86d4a13cb36401c7851522244b0df') { // Sys_ID for "Request Review to Unblock Google Extension or Application"
template.print("Google App/Ext: " + gr.variables.google_extension.getDisplayValue() + "\n");
}
if (gr.cat_item == 'f182a46b13a0c7001c7851522244b08d') { // Sys_ID for "Building Access - New, Replace or Change"
template.print(gr.variables.labor_type.getDisplayValue() + " requesting access to : " + gr.variables.selected_location.getDisplayValue() + "\n");
template.print("\n");
if (gr.variables.labor_type.getDisplayValue() == 'Vendor') {
template.print(gr.variables.what_action.getDisplayValue() + " for Vendor\n");
template.print("Project Information: " + gr.variables.vendor_project + "\n");
template.print("Company Name: " + gr.variables.vendor_company_name + "\n");
template.print("Access from: " + gr.variables.vendor_start_access + " to " + gr.variables.vendor_end_access + "\n");
} else {
template.print(gr.variables.what_action.getDisplayValue() + " for : " + gr.variables.reference_name.getDisplayValue() + "\n");
}
template.print("\n");
}
if (gr.cat_item == '78411b5613ff92001c7871522244b06f') { // Sys_ID for 'Google External Email Link Sharing'
template.print("Description: " + gr.short_description + "\n");
template.print("Request Type: " + gr.variables.request_type.getDisplayValue() + "\n");
if (gr.variables.content) {
template.print("Type of Content: " + gr.variables.content + "\n");
}
if (gr.variables.shared) {
template.print("To Be Shared With: " + gr.variables.shared + "\n");
}
}
if (gr.cat_item == '349e4a07133bd2001c7871522244b0f7') { // Sys_ID for "Website Access | Content Management"
/* Commenting as a part of STRY0013621
template.print("Access Recipient: " + gr.variables.requested_for.getDisplayValue() + "\n");
template.print("Selected Division: " + gr.context.scratchpad.selected_site + "\n");
template.print("Selected Application: " + gr.context.scratchpad.selected_app + "\n");
if (gr.context.scratchpad.selected_app == 'Elateral'){
template.print("Currently has AEM Access?: " + gr.context.scratchpad.has_aem_access + "\n");
}
if (gr.context.scratchpad.access_level) {
template.print("Access Level: " + gr.context.scratchpad.access_level + "\n");
}
if (gr.context.scratchpad.selected_property) {
template.print("Selected Property: " + gr.context.scratchpad.selected_property + "\n");
}
*/
template.print("Select Division: " + gr.variables.select_site.getDisplayValue() + "\n");
if (gr.variables.select_site == 'irvinecompanyapartment') {
template.print("What type of access do you need: " + gr.variables.select_application_apartments.getDisplayValue() + "\n");
template.print("Select your role: " + gr.variables.select_your_role_apt.getDisplayValue() + "\n");
}
if (gr.variables.select_site == 'irvinecompanyoffice') {
template.print("Requesting access to: " + gr.variables.select_application_office.getDisplayValue() + "\n");
template.print("Select your role: " + gr.variables.select_your_role_office.getDisplayValue() + "\n");
}
}
if (gr.cat_item == '26b832ee0a0a3ca1000e31716ca948a1') { // Sys_ID for "Change My Access"
template.print("Application: " + gr.variables.change_application + "\n");
template.print("Access Change: " + gr.variables.change_detail + "\n");
}
if (gr.cat_item == '77c4d71c0a0a3ca1011410a984447eea') { // Sys_ID for "General Request"
template.print("Short Description: " + gr.variables.short_description + "\n");
template.print("Description: " + gr.variables.what_needed + "\n");
}
if (gr.cat_item == '81ffbea40a0a3ca1015d8d9c472d8ce0') { // Sys_ID for "Shared Folder Access"
template.print("Shared Folder Path(s): " + gr.variables.shared_folder_path + "\n");
template.print("Access Type: " + gr.variables.access_type.getDisplayValue() + "\n");
}
if (gr.cat_item == 'df4491d20fa39a0062b6e64be1050ee1') { //sys_id for 'OneSite Additional Property Access'
template.print(gr.description + "\n");
}
if (gr.cat_item == '7d3a43aa0fcda78062b6e64be1050ec0') { // sys_id for 'Salesforce Access'
var sfAccessType = gr.context.scratchpad.new_access ? "New Access" : "Additional Access";
template.print("Access Type: " + sfAccessType + "\n");
template.print("Business Role: " + gr.context.scratchpad.business_role + "\n");
}
if (gr.cat_item == '1dbc5bbcdb0ff7009144f2713996195c' || gr.cat_item == 'a9b26af1874fd1104efd7488cebb35a2') { // Sys_ID for 'Qualtrics - Access or Request'
template.print("Requesting " + gr.variables.requesting.getDisplayValue() + " to " + gr.variables.selected_property.getDisplayValue() + "\n");
if (gr.variables.additional_details) {
template.print("Additional Details: " + gr.variables.additional_details + "\n");
}
template.print("\n");
}
if (gr.cat_item == '88145a13db929c109144f271399619a0') { //sys_id for ICAC PPM Financial Reports
template.print('For Functional Area: ' + gr.variables.functional_area.getDisplayValue());
template.print("\n");
}
if (gr.cat_item == 'b8660ddd1ba3c9108caa64e1604bcb1d') { //sys_id for Access to Blocked Web Sites
template.print('Web site URL: ' + gr.variables.web_site_url.getDisplayValue() + "\n");
template.print('Users that need access: ' + gr.variables.users_that_need_access.getDisplayValue());
template.print("\n");
}
if (gr.cat_item == gs.getProperty('imc.sc_cat_item.sap_ppm_application_access')) { //sys_id for 'SAP PPM - Application Access'
template.print('Division: ' + gr.variables.division.getDisplayValue() + "\n");
template.print('Role: ' + gr.variables.role.getDisplayValue() + "\n");
}
if (gr.cat_item == gs.getProperty('imc_cat_item_request_for_dba_team')) { //sys_id for 'Request for DBA Team'
template.print('\nItem Description: \n' + gr.description + '\n');
}
if (gr.cat_item == gs.getProperty('imc_cat_item_move_request')) { //sys_id for 'move request'
if (gr.variables.move_for == 'individual'){
template.print('\nItem Description: \n' + gr.description + '\n');
}
if (gr.variables.move_for == 'group')
{
var mrvs_data_group = '';
var mrvs_group = gr.variables.group_move_mrvs; //replace with the internal name of your MRVS
var rowCount = mrvs_group.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row_group = mrvs_group.getRow(i);
mrvs_data_group += '\n----------' + '\n' +
'User: ' + row_group.user.toString() + '\n' +
'To Home Base: ' + row_group.to_home_base_bulk.toString() + '\n' +
'To Floor: ' + row_group.to_floor_bulk.getDisplayValue() + '\n' +
'To Space: ' + row_group.to_space_bulk.toString() + '\n' +
'Date: ' + row_group.employee_requested_move_date + '\n' +
'From Home Base: ' + row_group.from_home_base.name + '\n' +
'From Floor: ' + row_group.from_floor.name + '\n' +
'From Space: ' + row_group.from_space.name + '\n' ;
}
template.print('Move Participants: ' + mrvs_data_group);
}
}
if (gr.cat_item == gs.getProperty('imc.sc_cat_item.field_move_req')) { //sys_id for 'Field Move Request'
var mrvs_data = '';
var mrvs = gr.variables.add_or_remove_users; //replace with the internal name of your MRVS
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
mrvs_data += '\n----------' + '\n' +
'Name: ' + getUserName(row.name) + '\n' +
'Current Building and Space #: ' + row.current_building_and_space + '\n' +
'New Building and Space #: ' + row.new_building_and_space + '\n' +
'Phone Number: ' + row.phone_number + '\n' +
'Additional Information: ' + row.additional_information + '\n';
}
template.print('When is the move?: ' + gr.variables.when_is_the_move.getDisplayValue() + mrvs_data);
}
if (gr.cat_item == 'f02e83e01b3cbfc49dd821bebd4bcb46') { //sys id for SP&A SAP GL
template.print('For Dataset:\n');
if (gr.variables.all == 'true')
template.print('- All divisions\n');
if (gr.variables.apartments == 'true')
template.print('- Apartments\n');
if (gr.variables.homebuilding == 'true')
template.print('- Homebuilding\n');
if (gr.variables.office == 'true')
template.print('- Office\n');
if (gr.variables.resorts == 'true')
template.print('- Resorts\n');
if (gr.variables.retail == 'true')
template.print('- Retail\n');
}
if (gr.cat_item == gs.getProperty('imc.sc_cat_item.ncd_parking_transponder')) { //sys id for 'NCD Parking Transponder'
if (gr.variables.pt_consultant == 'yes') {
template.print('\nIs this for an Irvine Company employee?: Yes');
template.print('\nEmployee Number: ' + gr.variables.pt_employee_number);
}
if (gr.variables.pt_consultant == 'no') {
template.print('Is this for an Irvine Company employee?: No');
template.print('\nIrvine Company Contact: ' + gr.variables.pt_tic_contact.getDisplayValue());
}
//template.print('\nRequested for: '+gr.variables.pt_req_firstname +' '+gr.variables.pt_req_lastname);
template.print('\nFirst name of the person: ' + gr.variables.pt_req_firstname);
template.print('\nLast name of the person: ' + gr.variables.pt_req_lastname);
template.print('\nEmergency Phone Number: ' + gr.variables.pt_main_phone);
template.print('\nBusiness Address: ' + gr.variables.pt_bus_address);
template.print('\nBusiness Phone: ' + gr.variables.pt_bus_phone);
template.print('\nEmail: ' + gr.variables.pt_email);
if (gr.variables.pt_transponder_type != 'replace') {
template.print('\nVehicle Make and Model: ' + gr.variables.pt_car_type);
template.print('\nVehicle License #: ' + gr.variables.pt_car_license);
if (gr.variables.pt_car_alt_type != '') {
template.print('\nAlternate Make and Model: ' + gr.variables.pt_car_alt_type);
}
if (gr.variables.pt_car_alt_license != '') {
template.print('\nAlternate License #: ' + gr.variables.pt_car_alt_license);
}
template.print('\nType of parking condition: ' + gr.variables.pt_radio + '\n');
}
}
if (gr.variables.price) {
template.print("Unit Price: " + gr.variables.price + "\n");
} else if (gr.cat_item.price > 0) {
template.print("Unit Price: $" + gr.cat_item.price + "\n");
}
if (gr.quantity > 1) {
template.print("Quantity: " + gr.quantity + "\n");
}
if (gr.variables.business_justification) {
template.print("Business Justification: " + gr.variables.business_justification + "\n");
}
var nh = new GlideRecord('sc_req_item'); //Check if part of New Hire Request
nh.addQuery('request', current.sysapproval.request);
nh.addQuery('cat_item', 'a803796c454f75002d7c55b3887df3b0'); //Sys_ID of "SD: New Hire" Catalog Item
nh.query();
if (nh.next()) {
if (nh.variables.contractor == "Yes" || nh.variables.contractor == "yes") {
template.print("Contractor: " + nh.variables.contractor + "\n");
template.print("Contractor start date: " + nh.variables.nh_start_date + "\n");
template.print("Contractor end date: " + nh.variables.con_end_date + "\n");
template.print("Location: " + nh.variables.location + "\n");
}
}
if (gr.request.special_instructions) {
template.print("Special Instructions: " + gr.request.special_instructions + "\n");
}
if (gr.variables.purchase_info) {
template.print("Purchase Information: " + gr.variables.purchase_info + "\n");
}
template.print('<hr color="#6D7B8D" />');
var mailToAddress = gs.getProperty('glide.email.user');
template.print('\n\n<a href="mailto:' + mailToAddress + '?subject=Re%3A${sysapproval}%20-%20approve&body=%0D%0A%0D%0A%0D%0A-----------------------------------%0D%0AOptional:%20Please%20provide%20any%20additional%20information%20above%20the%20line.%20Do%20not%20modify%20any%20content%20below%20the%20line.%0D%0A${watermark}"><img src="/IMT-Solutions-ApproveButton.png" alt="Click here to approve ${sysapproval}" /></a>\n\n');
template.print('<a href="mailto:' + mailToAddress + '?subject=Re%3A${sysapproval}%20-%20reject&body=%0D%0A%0D%0A%0D%0A-----------------------------------%0D%0AOptional:%20Please%20provide%20any%20additional%20information%20above%20the%20line.%20Do%20not%20modify%20any%20content%20below%20the%20line.%0D%0A${watermark}"><img src="/IMT-Solutions-DenyButton.png" alt="Click here to deny ${sysapproval}" /></a>\n\n');
template.print('<hr color="#6D7B8D" />');
template.print('Additional Information:\n');
template.print("Supervisor's Name: " + gr.request.requested_for.manager.name + "\n" + "Supervisor's Division: " + gr.request.requested_for.u_division.getDisplayValue());
if (gr.request.requested_for.location) {
template.print("\n" + "Supervisor's Location: " + gr.request.requested_for.location.name);
}
template.print('\n\n');
var findReq = new GlideRecord('sc_request');
findReq.addQuery('sys_id', gr.request);
findReq.addNotNullQuery('u_details');
findReq.query();
if (findReq.next()) {
template.print("The above item was requested for the below NEW HIRE: \n" + findReq.u_details);
}
}
var html = '<a style="color:#0086AE" href="/it">click here</a>';
template.print("To see pending approvals, " + html + ".\n\n");
template.print("Thank you,\n\n");
template.print("<a style='color:#0086AE' href='/it'>IT Service Desk</a>\n");
template.print("949.720.4357");
function getUserName(userSysID) {
var grUser = new GlideRecord('sys_user');
grUser.get(userSysID);
return grUser.u_name_id.toString();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 10:35 AM
Hi @sinu2 ,
The root cause is MVRS will not get the object to dot walk to name field. It has only backend values & sysids to carry. IF you need to print the display names, you need to gliderecord & display.
Mark as accepted solution & Hit helpful if it suffice your requirement !!