To display contractor's names from multi row variable set in short description.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 12:41 AM
Hello,
I need to display the contractor's names(max limit=5) from a multi row variable set in the short description based on the type of access requested in the catalog form. I have written a code but it is not executing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 01:38 AM
Hi,
You can ensure your code executes, verify that the variable sets are correctly referenced and that the loop conditions are properly set. Also, check if the type_of_access variable is correctly capturing the user’s input. If issues persist, consider debugging with console logs or seeking help from a developer familiar with the platform you’re using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 05:34 AM
This is a good first attempt. Have you added log statements inside each if block to confirm that the script is running, and check field/variable values? SInce you are using 'current' is this script in a workflow Run Script activity or Business Rule? Try changing variable_set to variables, and using getRowCount(), and a catch-all 'else', so it would look more like this:
gs.info('myScript: running');
if (current.variables.type_of_access == "New Contractor Access") {
gs.info('myScript new:' + current.variables.type_of_access);
var mrvs_1 = current.variables.new_contractor_access;
var rowCount_1 = mrvs_1.getRowCount();
var desc_1 = '';
for(var i=0; i<rowCount_1; i++){
var row_1 = mrvs_1.getRow(i);
desc_1 += current.variables.type_of_access + " for " + row.first_name + "\n";
}
current.short_description = desc_1 + '\n\n';
} else if (current.variables.type_of_access == "Extend a Contractors Access") {
gs.info('myScript extend:' + current.variables.type_of_access);
var mrvs_2 = current.variables.extend_contractor;
var rowCount_2 = mrvs_2.getRowCount();
var desc_2 = '';
for(var j=0; j<rowCount_2; j++){
var row_2 = mrvs_2.getRow(j);
desc_2 += current.variables.type_of_access + " for " + row.extend_contractor_name + "\n";
}
current.short_description = desc_2 + '\n\n';
} else if (current.variables.type_of_access == "Remove Contractors Access") {
gs.info('myScript remove:' + current.variables.type_of_access);
var mrvs_3 = current.variables.remove_contractor;
var rowCount_3 = mrvs_3.getRowCount();
var desc_3 = '';
for(var k=0; k<rowCount_3; k++){
var row_3 = mrvs_3.getRow(k);
desc_3 += current.variables.type_of_access + " for " + row.remove_contractor_name + "\n";
}
current.short_description = desc_3 + '\n\n';
} else if (current.variables.type_of_access == "Update Contractors Details") {
gs.info('myScript update:' + current.variables.type_of_access);
var mrvs_4 = current.variables.update_contractors_details;
var rowCount_4 = mrvs_4.getRowCount();
var desc_4 = '';
for(var l=0; l<rowCount_4; l++){
var row_4 = mrvs_4.getRow(l);
desc_4 += current.variables.type_of_access + " for " + row.update_contractor_name + "\n";
}
current.short_description = desc_4 + '\n\n';
} else {
gs.info('myScript else:' + current.variables.type_of_access);
}