Getting [object GlideRecord] for some of Input variables in Script Step of Action payload

Avinash Kumar K
Tera Expert

Hi,

Getting [object GlideRecord] for some of Input variables in Script Step of Action called from Flow. 

 

Payload which i got {"sintCompanyCode":1,"strAssetCode":"89411DU8","strCategory":"[object GlideRecord]","strSubCategory":"laptop"}.

Here Category is reference variable, reference to model category table

 

SCRIPT STEP ;

(function execute(inputs, outputs) {
    // Extract and validate inputs
    var companyCode = inputs["company_code"] ? inputs["company_code"].toString() : "";
    var assetCode = inputs["asset_code"] || "";
    var category = inputs["category"] ? inputs["category"].toString() : "";
    var subcategory = inputs["subcategory"] || "";

    // Ensure company code is a valid number
    var sintCompanyCode = parseInt(companyCode, 10);
    if (isNaN(sintCompanyCode)) {
        outputs["error_message"] = "Invalid company_code: " + companyCode;
        return;
    }

    // Construct the payload object
    var payload = {
         "lstAssetDetails": [
            {
                "sintCompanyCode": sintCompanyCode, // Ensure company code is an integer
                "strAssetCode": assetCode.toString(), // Convert asset code to string if needed
                "strCategory": category.toString(), // Ensure make is a string
                "strSubCategory": subcategory.toString() // Ensure model is a string
            }
        ]
    };

    // Serialize the payload as JSON and set it in the output
    try {
        outputs["asset_details"] = JSON.stringify(payload);
    } catch (error) {
        outputs["error_message"] = "Failed to stringify payload: " + error.message;
    }
})(inputs, outputs);

 

 

5 REPLIES 5

Hi @Valmik Patil1 

Kindly find the screenshot i had attached for Inputs