Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

I want to show rich text label after template upload

Dipali_Pawar
Tera Contributor

Hi , 

 

I have one form where need to upload template and that template has factory id column so if factory id does not exist it should show factory id not found  and that part is working correctly , i have done that using script include and that is not client callable , now one more requirement is if factory id not found  then it should show message to user please click here to raise request and here word should link to other catalog item .

so what I did is I created rich text label and there I have inserted the catalog item link and i was trying to achieve this with on change of upload button if validation error.includes ('Factory not found') then show rich text label but that is not working as expected it's working second time when i am uploading template again because that time validation errors loaded but that should not be the case and same reuirement if factory is not linked to company. only label will change 

 

please let me know if anyone has worked on similar requirement . please find the sample code for reference

 

_validateFactories: function(row) { // DP
        // Dp check
        var factoryId = row['Factory ID'];
        if (factoryId) {
            var invalidFactoryId = [];
            var fields = this.ARTICLE_FIELDS;
            fields = fields.toString();
            var factoryGR = new GlideRecord('x_asda_factories_factory');
            factoryGR.addQuery('correlation_id', factoryId);
            factoryGR.query();
            if (!factoryGR.next()) {
                invalidFactoryId.push('Factory ID is not found : ' +factoryId);
            }
else{
var userCompany = gs.getUser().getCompanyID();
var factoryAccount = new GlideRecord('x_asda_factories_m2m_factories_accounts');
factoryAccount.addQuery('name',factoryGR);
factoryAccount.addQuery('name',userCompany);
factoryAccount.query();
if(!factoryAccount.next()){
invalidFactoryId.push('Factory ID is not linked to your company : ' +factoryId);
}
 
}
        }
        return invalidFactoryId;
 
    },
 
 
 
 
 
// on same script include passing the error
 
if (validatedRow['factory_id'].length > 0)  //DP
 
       rowsValidationSummary.push(' Factory validation errors: ' + validatedRow['factory_id'].join(';'));
 
 
 
 
 

 

 

 

 

 

Thanks, 

 

 

6 REPLIES 6

@Dipali_Pawar Display BR runs on load and stores some value in g_scratchpad.

 

That value does not change until the form is loaded again i.e. it may not work on change.


Raghav
MVP 2023
LinkedIn

yeah so what i am thinking is check the condition if attachment errors includes Factory id not found and storing to g_scratchpad and pass it in on load script.