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

RaghavSh
Mega Patron

@Dipali_Pawar Can you share the code written on Change?


Raghav
MVP 2023
LinkedIn

Hi @RaghavSh , please find below code

 

var erromsg = g_form.getValue('stage2_attachment_errors');
if(erromsg.includes("Factory ID not found")){
    alert('incorrect');
    g_form.setDisplay('factory_link',true);

}
else{
    g_form.setDisplay('factory_link',false);

}

I believe anything called from client script should be client callable.

 

is there a way you can share full code?


Raghav
MVP 2023
LinkedIn

But my script include is not a client callable that is the issue. I am trying with display BR but that also not working