Order guide variables on RITM needs to be editable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 01:14 AM
Hi,
There is a order guide, when ordered 2 RITMS are generated. The fields from the order guide are cascaded onto the catalog item. The variable editor of the RITMs have the order guide variables and Catalog items variables.
The task here is to make the variables editable when the logged in user is same as the member in the requested for field of the RITM.
I have written a client script with condition reqfor == loguser and used setVariablesReadOnly(false), but it is making only the catalog items variables editable. The variables from the order guide present on the variables section of RITM are not being editable.
Any help on this is appreciated.
Thanks in Advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 08:11 AM
Hi @Naga14
I think to make the variables from the order guide editable, you need to handle them separately in the client script. Here's a sample client script that should work for making both catalog item variables and order guide variables editable based on the condition:
function onLoad() {
var reqFor = g_form.getValue('requested_for');
var logUser = g_user.userID;
// Make all variables editable initially
g_form.setVariablesReadOnly(false);
// Loop through the variables and make specific ones read-only based on the condition
var variables = g_form.getVariables();
for (var i = 0; i < variables.length; i++) {
var variable = variables[i];
// Check if the variable is from the order guide
if (variable.getTableName() === 'sc_order_guide_variable') {
// Replace 'order_guide_variable_name' with the actual name of the variable from the order guide you want to check
if (variable.getName() === 'order_guide_variable_name' && logUser !== reqFor) {
// If the logged-in user is different from the requested_for user, make the order guide variable read-only
variable.getElement().disabled = true;
}
} else {
// Check for catalog item variables and apply the same condition if required
// Replace 'catalog_variable_name' with the actual name of the catalog item variable you want to check
if (variable.getName() === 'catalog_variable_name' && logUser !== reqFor) {
// If the logged-in user is different from the requested_for user, make the catalog item variable read-only
variable.getElement().disabled = true;
}
}
}
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:07 AM