Client Script RemoveCurrentPrefix Error

NMMZ10
Tera Contributor

Hi!

I'm currently developing a client script on Incident table, but when I'm testing it, it gives me an error that i don't understand.

Its a simple script and it shouldn't allow in new or existing incidents

 

How can i solve this?

2 ACCEPTED SOLUTIONS

Anand Kumar P
Giga Patron

Hi @NMMZ10 ,

In client script you access with g_form no need new object like below:

 

var category = g_form.getValue('category');

var priority = g_form.getValue('priority');


Use below script it will work.

function onSubmit() {

    var category = g_form.getValue('category');

    var priority = g_form.getValue('priority');

    if (category == 'database' && priority == '1') {

        g_form.addInfoMessage('Critical incidents are not allowed for category Database');

        return false;

    }

    return true;

}

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand

View solution in original post

Juhi Poddar
Kilo Patron
Kilo Patron

Hello @NMMZ10 

Please try this script:

function onSubmit() {
    var category = g_form.getValue('category');
    var priority = g_form.getValue('priority');

    if (category == 'database' && priority == '1') {
        g_form.addInfoMessage('Critical incidents are not allowed for category Database');
        return false; // Prevent form submission
    }

    return true; // Allow form submission
}

Screenshot onSubmit Client Script:

JuhiPoddar_0-1734515724240.png

Screenshot Info message:

JuhiPoddar_1-1734515879570.png

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

 

View solution in original post

3 REPLIES 3

Anand Kumar P
Giga Patron

Hi @NMMZ10 ,

In client script you access with g_form no need new object like below:

 

var category = g_form.getValue('category');

var priority = g_form.getValue('priority');


Use below script it will work.

function onSubmit() {

    var category = g_form.getValue('category');

    var priority = g_form.getValue('priority');

    if (category == 'database' && priority == '1') {

        g_form.addInfoMessage('Critical incidents are not allowed for category Database');

        return false;

    }

    return true;

}

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand

Juhi Poddar
Kilo Patron
Kilo Patron

Hello @NMMZ10 

Please try this script:

function onSubmit() {
    var category = g_form.getValue('category');
    var priority = g_form.getValue('priority');

    if (category == 'database' && priority == '1') {
        g_form.addInfoMessage('Critical incidents are not allowed for category Database');
        return false; // Prevent form submission
    }

    return true; // Allow form submission
}

Screenshot onSubmit Client Script:

JuhiPoddar_0-1734515724240.png

Screenshot Info message:

JuhiPoddar_1-1734515879570.png

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

 

Juhi Poddar
Kilo Patron
Kilo Patron

Hello @NMMZ10 

Thanks for marking my post helpful.

As per the new community policy you can mark multiple correct answers.

Can you please mark my answer as an accepted solution, so that others can find the solution easily and supports community.

 

Thank You

Juhi Poddar