Add message on Company Entry screen for customer on hold in Sage 300

I've tried numerous times to get a script to work that will show as an error message (in Red) that the customer is on hold. There is an old article showing the steps for "Customer on Hold" for CRM 7.0. Current client is on 7.3 sp3 and we are unable to get it to show anything. Below is the script that I have been trying to use in the Custom Content in the Company Entry Screen. ARCUS is setup as a connection to the Sage 300 datatable.

<script>
crm.ready(function ()
{

var ArAccpacCust = eWare.FindRecord("ARCUS", "IDCUST='" + Values('comp_idcust') + "'");

var bOnHold = ArAccpacCust('SWHOLD');

{
if (bOnHold == 1) {
crm.errorMessage("On Hold");
}
}

})
</script>

Any help would be appreciated.

  • 0

    Terry

    You are mixing server-side script within client-side.

    The eWare.FindRecord and Values() are server-side and the type of methods you would use in a create script.

    For example on the company name field (other other field) the create script could be

    var ArAccpacCust = eWare.FindRecord("ARCUS", "IDCUST='" + Values('comp_idcust') + "'");

    var bOnHold = ArAccpacCust('SWHOLD');

    {

    if (bOnHold == 1) {

    Valid = false;

    ErrorStr = "On Hold";

    }

    }

  • 0

    Thanks Jeff. Appreciate the direction.

  • 0

    I've looked at this further using custom content scripting for other fields. I can get your example to highlight fields to work with this.

    crm.ready(function()

    {

    if (crm("comp_status").value()== "Inactive")

    {

    crm.errorMessage("Customer is INACTIVE");

    }

    })

    The field I want to look at is comp_codeterm so I change the above to this.

    crm.ready(function(){

    if (crm("comp_codeterm").value()== "CASH")

    {

    crm.errorMessage("Customer is CASH only");

    }

    })

    Now, i get nothing. There is a column for codeterm in the company table and there are values. Is this field treated different?

  • 0

    Terry

    Are you familiar with the Chrome developer tools and console? If you navigate to your company page in CRM using Chrome, then press F12 you will open the developer tools. Make sure that you are on the console tab. You can then enter clientside JavaScript directly in the console and this allows you to experiment and test objects.

    For example you can test to see if you field is accessible to the clientside API

    var myfield = crm("comp_codeterm")

    should return an object and you can then check its value

    myfield.value()

    You can see how I have done this he community.sagecrm.com/.../sage-crm-v7-2-the-new-client-side-api.aspx

  • 0

    Yes, I have looked at that plus the others that you have written. They have helped.

    Tried your suggestion many times and returns the value "Null". Must be something else going on with this field as it does exist.

  • 0

    OK. In the HTML of the page is the field wrapped with s?

    Sage CRM puts Standard Ids round all captions and data

    The example above shows the oppo_description field

    _Captoppo_description

    _Dataoppo_description

    This means that you should be able to get hold of the field using something like

    document.getElementbyID("comp_codeterm")