Setting up a RITM Short Description & Description form catalog variable.

Chinmay_Batra
Tera Contributor

Usecase: We want to copy Short Description and Description from catalog variables to RITM table Short description and Description.

There are 3 conditions in use case:
1. It will check in the catalog "Short Description" variable that it is having the data or not. If the data is present in the short description variable, then it'll pass the data to the RITM "Short description" field.
2. If the data is not present in the catalog "Short Description" variable then it'll copy the "Catalog Item Name" and "Requested for" in RITM "Short Description" field.
3. It will check in the catalog "Description" variable that it is having the data or not. If the data is present in the "Description" variable, then it'll pass the data to the RITM "Description" field.

 

Chinmay_Batra_0-1701537503977.png1. For this we need to write "Before Business Rule" in the RITM table on "insertion" of value.

Chinmay_Batra_1-1701537663265.png


2. Script: 
Chinmay_Batra_2-1701537712701.png

Chinmay_Batra_5-1701540085976.png

 

Here I am passing data for both the variables "Short Description & Description" & it will pass both the variable data to RITM "Short Description & Description" field (refer below image).

Chinmay_Batra_4-1701539964402.png

 

(function executeRule(current, previous /*null when async*/) {

    // Condition 1st: Checking for "Short Description" variable if value is present in the variable or not If value is there then copy the same value to RITM "Short Description" field.
    if (current.variables.short_description){
        current.short_description = current.variables.short_description;
    }
Chinmay_Batra_12-1701541670150.png

Here I am passing data of "Short Description" & it will pass the "Short Description" variable data to RITM "Short Description" field (refer below image).

Chinmay_Batra_6-1701540408673.png

 


    // Condition 2nd: Checking for Short Description variable is empty. If Short Description variable is empty then copy the "Catalog Item Name" and "Requested for" in RITM Short Description field. If both Short Description and Requested for variables are empty then pass the "Catalog Item Name" in "Short Description" field.
    if (!current.variables.short_description){
        if(current.variables.requested_for){
            current.short_description = current.cat_item.getDisplayValue() +'- '+ current.variables.requested_for.getDisplayValue();
        } else{
            current.short_description = current.cat_item.getDisplayValue();
        } //if Requested for is not available
    }
Chinmay_Batra_7-1701540462595.png
Here I am passing "Short Description" variable as empty It'll take catalog name and requested for as a short description in RITM "Short Description" field (refer below image).

Chinmay_Batra_8-1701540518877.png

 

Chinmay_Batra_9-1701540557690.png
Here I am passing "Short Description & Requested for" variables as empty It'll take catalog name as a short description in RITM "Short Description" field (refer below image).

Chinmay_Batra_10-1701540586173.png

 

// Condition 3rd: Checking for Description variable if value is present in the variable or not If value is there then copy the same value to RITM "Description" field.
    if (current.variables.description){
        current.description = current.variables.description;
    } })(current, previous);

Chinmay_Batra_13-1701541864184.png


Here I am passing data of "Description" & it will pass the "Description" variable data to RITM "Description" field (refer below image).

Chinmay_Batra_11-1701540729464.png

 


Note: I have taken an example of "Description" and "Short Description" variable likewise you can use, variables as per your requirements.

Thank you,
Chinmay Batra

 

0 REPLIES 0