Validation Script

Hello community

I am currently working on a script in Sage CRM 2023 R2 based on the examples provided in the admin documentation. However, I am facing an issue with my conditional logic, and despite following the examples, it doesn't seem to be working as expected.

Here's the specific code snippet I'm having trouble with:

if (Values('quit_listprice') > 0 && 
    Values('quit_listprice') !== Values('quit_quoteprice') &&
    CurrentUser.user_primarychannelid !== 7) {
    Valid = false;
    ErrorStr = "Please ask authorization from Management";
}

// The code isn't working as expected, even when I remove the channel check from the logic.

I would greatly appreciate any insights, suggestions, or corrections that the community can provide.

Thank you in advance for your assistance!

Code in the admin documentation

if (Values('oppo_certainty')<25 && Values('oppo_priority')!='Low')
    {
        Valid=false;
        ErrorStr="please set the priority to Low";
    }

  • 0

    I have just logged a case internally about this.

    There seems to be an issue with QuoteItems and OrderItems displaying validation messages.

    For example if the following basic test script is added to QuoteSummary (quot_status) then the message will be displayed on the screen.

    Valid = false;
    ErrorStr = "Hello World";

    BUT  if you add the validate script in the Quote Item screen (QuoteItemsSummary) on the quit_listprice field it will prevent the record being committed BUT will not display the message. 

  • 0 in reply to Sage CRM

    Thank you for your response Sage CRM.

    While the example code you provided prevents the saving of the line item, my code does not seem to have the same effect.

    I would appreciate it if my code could at least prevent the user from saving the line item, even if the error string doesn't show up. 

    Thank you.

  • 0 in reply to SAMUEL MAIA

    Hi Samuel,

    I have tried your script as well - and found two typos in it. Correct these and it will work (just without the Error String as SageCRM has already mentioned)

    Change your !== to just != and secondly change the the reference from quit_quoteprice to quit_quotedprice