- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 10:51 PM - edited 09-23-2024 02:11 AM
Hi all,
I need to submit a catalog item in the order guide. In the order guide we have MRVS variable which has variables of application. If application is value set to Value1. Then Catalog item 1 need to submitted.
But to achieve this I tried to add the rule base , but it's not support to add rule base for MRVS variable.
How can I achieve this? Can someone suggest on this.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 04:30 AM
Add an "onSubmit" catalog client script to the order guide. This script will loop through the MRVS data and check the values of the "application" variable.
sample code of client script, make changes as per your requirement here:
function onSubmit() {
var mrvField = g_form.getValue('your_mrvs_variable');
var mrvData = JSON.parse(mrvField); // Parse the MRVS JSON data
var shouldSubmitItem1 = false;
// Loop through the MRVS rows to find the application value
for (var i = 0; i < mrvData.length; i++) {
var applicationValue = mrvData[i].application; // Adjust the field name to match your MRVS
if (applicationValue == 'Value1') {
shouldSubmitItem1 = true;
break;
}
}
// Submit the Catalog Item 1 based on the condition
if (shouldSubmitItem1) {
// Use g_form.submit or custom logic to submit the required catalog item
submitCatalogItem1();
}
}
function submitCatalogItem1() {
// Custom logic to submit Catalog Item 1 programmatically
// This might involve using GlideAjax to trigger a server-side process
}
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 05:18 AM - edited 09-23-2024 05:18 AM
If using an Order Guide yes/no variable named 'v_catalog_item' in an MRVS with the internal name 'application_mrvs' which has the application variable named 'v_application', this is what the onSubmit Catalog Client Script looks like:
function onSubmit() {
var cat_item = false;
var mrvs = g_form.getValue('application_mrvs');
if (mrvs.length > 2) { //native UI returns [] for empty MRVS value which causes a parsing error
var obj = JSON.parse(mrvs);
for (var i = 0; i < obj.length; i++) {
if (obj[i].v_application == '<<sys_id or value of certain application>>') {
cat_item = true;
break; //we found one, so no need to continue
}
}
}
if (cat_item) {
g_form.setValue('v_catalog_item', 'Yes');
}
}
Rule Base example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 03:40 AM
What you need to do is create an Order Guide variable with a unique name so it doesn't cascade to the Catalog Item(s). Let's make this a yes/no variable for this example, but you can choose a different type once you see the approach. You can hide this variable on the request form,... so that it doesn't show anywhere. In an onSubmit Catalog Client Script that applies to the Catalog Item = the Order Guide (OG onSubmit scripts run when the Choose Options / next button is clicked) you would write a script that retrieves the contents of the MRVS, then loops through them to test if any row has an application 'is value set to Value1'. If it finds on, set the yes/no variable to 'Yes'. Then you would add or change the Rule Base to include Catalog item 1 with the condition <<new variable name>> is Yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 04:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 05:18 AM - edited 09-23-2024 05:18 AM
If using an Order Guide yes/no variable named 'v_catalog_item' in an MRVS with the internal name 'application_mrvs' which has the application variable named 'v_application', this is what the onSubmit Catalog Client Script looks like:
function onSubmit() {
var cat_item = false;
var mrvs = g_form.getValue('application_mrvs');
if (mrvs.length > 2) { //native UI returns [] for empty MRVS value which causes a parsing error
var obj = JSON.parse(mrvs);
for (var i = 0; i < obj.length; i++) {
if (obj[i].v_application == '<<sys_id or value of certain application>>') {
cat_item = true;
break; //we found one, so no need to continue
}
}
}
if (cat_item) {
g_form.setValue('v_catalog_item', 'Yes');
}
}
Rule Base example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2024 04:30 AM
Add an "onSubmit" catalog client script to the order guide. This script will loop through the MRVS data and check the values of the "application" variable.
sample code of client script, make changes as per your requirement here:
function onSubmit() {
var mrvField = g_form.getValue('your_mrvs_variable');
var mrvData = JSON.parse(mrvField); // Parse the MRVS JSON data
var shouldSubmitItem1 = false;
// Loop through the MRVS rows to find the application value
for (var i = 0; i < mrvData.length; i++) {
var applicationValue = mrvData[i].application; // Adjust the field name to match your MRVS
if (applicationValue == 'Value1') {
shouldSubmitItem1 = true;
break;
}
}
// Submit the Catalog Item 1 based on the condition
if (shouldSubmitItem1) {
// Use g_form.submit or custom logic to submit the required catalog item
submitCatalogItem1();
}
}
function submitCatalogItem1() {
// Custom logic to submit Catalog Item 1 programmatically
// This might involve using GlideAjax to trigger a server-side process
}
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh