How to pass a variable value from one catalog item to another.

Prithvi Ramesh1
Mega Sage

I have one use case wherein in a order guide "New Hire" we want to populate the Hiring Managers email id to the "Preferred Email address" in the New Email Account section.

 

 

function onLoad() {
    // Get the reference to the 'hiring_manager' field
    g_form.getReference('hiring_manager', function(reference) {
        // Callback function to execute after the reference is fetched
        if (reference) {
            // Reference is fetched successfully
            var hiringManager = reference.email;
            alert('Hiring Manager: ' + hiringManager);

            // Get the table name of the current form
            var currentTable = g_form.getTableName();
            alert('Current Table: ' + currentTable);

            // Check if the form's category is a specific one and 'new_email' is empty
            if (currentTable == 'ni' && g_form.getValue('new_email') === '') {
                alert('Inside if condition');
                alert('Current Table: ' + currentTable);
                alert('new_email: ' + g_form.getValue('new_email'));

                // Set the value of the 'new_email' field to the 'hiring_manager' value
                g_form.setValue('new_email', hiringManager);
                
                alert('new_email after setting: ' + g_form.getValue('new_email'));
            }
        } else {
            // Unable to fetch the reference
            alert('Unable to fetch reference for hiring_manager');
        }
    });
}

have written this code but still not working

2 ACCEPTED SOLUTIONS

Shubham Singh
Mega Guru

Hi @Prithvi Ramesh1 

 

You can use the Cascade variable present in the Order Guide. The following are the steps:

  1. Check the Cascade Variables checkbox to True.
  2. Create "Hiring Managers" variable on both Order Guide or Catalog item level (Assuming catalog item already added in the rule base).
    • NOTE: The backend name of the variable should be the same on both the Order Guide and Catalog item.
    • ALTERNATE: You can create a variable set if you would like to use multiple variables on both the Order Guide and catalog item level. Add the variable set on OG and Item both.

ShubhamSingh_0-1699973417141.png

 

Now whatever you fill on the variable on the Order Guide form, the same will get copied to the variable on the catalog item form. (Because we already marked Cascade Variables as TRUE in step 1)

 

Thanks!


Please mark this response as correct and helpful if it helps you ✔️👍

View solution in original post

@Prithvi Ramesh1 , hope this help to achieve the desire result, please mark as accept solution to close this thread for others.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

5 REPLIES 5

AshishKM
Kilo Patron
Kilo Patron

Hi @Prithvi Ramesh1 ,

You can configure the "Hiring Managers" field ( or common fields ) at order guide level and set the cascade checkbox, then matching variable will pass the value from "Describe Needs" to "Choose Options".

 

AshishKMishra_0-1699971796274.png

 

-Thanks

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Can you explain it in more detail

The order guide has this cascade option to pass variable value to selected catalog item if variable names are same. let's say, you are the hiring manager and giving your email on order guide level which is the first form under "Describe Needs" then you choose some other selection for catalog item(s) which are already defined under the "Rule Base" , based on selection the catalog item(s) will display and you can complete the form. Here, if the variable name are same in order guide and catalog item then it will show the email ( pre-filled ).

 

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

@Prithvi Ramesh1 , hope this help to achieve the desire result, please mark as accept solution to close this thread for others.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution