Not able to save business rule

Saroj Patel
Tera Expert

SarojPatel_0-1705298762382.png

Error MessageonSubmit script error: TypeError: Cannot read properties of undefined (reading 'replace'):
function onTemplateFieldSubmit() {
      var allowMultipleCarets = false;
      var CaretValidationError = function(message) {
       this.message = message;
      };
      var validationFunc = function(stringVal) {
       if(stringVal.match(/\^\^/))
        throw new CaretValidationError(getMessage("Your template contains an invalid character sequence: multiple carets"));
      };

      try {
       var cfilter = getFilter(fname, true, allowMultipleCarets ? null : validationFunc);
      } catch (err) {
       if (err instanceof CaretValidationError) {
        g_form.addInfoMessage(err.message);
        return false;
       }
      }

                     cfilter = cfilter.replace(/\^NQ/g, "^");
                     hinput.value = decodeURIComponent(cfilter);
      CustomEvent.fire("sys_mapping:on_cond_submit::" + fname, { value: hinput.value, ref: fname });
                 }


This error I'm getting

10 REPLIES 10

Anil Lande
Kilo Patron

Hi,

Are you facing this issue on PDI or customer instance?

Have you tried creating or updating any other BR? Is it happening for all record?

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Aniket Chavan
Tera Sage
Tera Sage

Hello @Saroj Patel ,

Please give a try to the script below and let me know how it works for you , also give feedback on the questions which are asked by @Anil Lande , so that it could help us to resolve your issue.

function onTemplateFieldSubmit() {
    var allowMultipleCarets = false;

    var CaretValidationError = function(message) {
        this.message = message;
    };

    var validationFunc = function(stringVal) {
        if (stringVal.match(/\^\^/)) {
            throw new CaretValidationError("Your template contains an invalid character sequence: multiple carets");
        }
    };

    try {
        var cfilter = getFilter(fname, true, allowMultipleCarets ? null : validationFunc);

        // Check if cfilter is undefined before attempting to replace
        if (cfilter !== undefined) {
            cfilter = cfilter.replace(/\^NQ/g, "^");

            // Assuming hinput is defined somewhere in your code
            if (hinput !== undefined && hinput.value !== undefined) {
                hinput.value = decodeURIComponent(cfilter);
                CustomEvent.fire("sys_mapping:on_cond_submit::" + fname, { value: hinput.value, ref: fname });
            } else {
                console.error("hinput is undefined or hinput.value is undefined");
            }
        } else {
            console.error("cfilter is undefined");
        }
    } catch (err) {
        if (err instanceof CaretValidationError) {
            g_form.addInfoMessage(err.message);
            return false;
        } else {
            console.error("Unexpected error:", err);
        }
    }

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

Aniket Chavan
Tera Sage
Tera Sage

Hello @Saroj Patel ,

Previously I didn't understood your issue properly but accidently today I also faced the same issue while working, like I was also not able to save or change anything in business rule

 

AniketChavan_0-1705322152459.png
Then I just logged in to my instance in "Incognito window" and tried to save the same business rule record and at that I time I didn't faced any issue, but at the same time I am currently still facing the issue in normal chrome window and I have tried to log out and again login, cleared the cache.

 

but for a time being you can use the Incognito mode to work and make changes, till then I will try and fix the issue and let you know about further updates

 

Let me know your views on this and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

 

@Aniket Chavan are you facing on PDI?

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande