We are trying to get some CRM field validation working on a pair of fields on Sage1000 v6.1r.
The two fields are:
fstk_inprice_list – a checkbox, so Boolean field.
fstk_product_type – a multiselect with the following values:
Live – live
Non-Sales Item – nonsales
Non-Stock Item – nonstk
Obsolete Product – obs
Obsolete when Nill Stock – obsnill
No Product Image – noimg
We are trying to get CRM to prevent a single item, that has fstk_inprice_list AND fstk_product_type with a value of Obsolete Product – obs being selected at the same time, and Sage letting the record be saved. We would like this to be prevented. We have got the code for the checkbox working on its own, but cannot work out how to make the multiselect work properly – it works partially, but if you have multiple items selected in the multi-select it starts to break.
We do appreciate that it may be necessary to amend the short codes for our entries as there is crossover in them.
Below is the code we have been trying, in various forms:
var stringA = (Values('fstk_product_type'));
if (stringA.indexOf(",obs,")> -1)
{
Valid=false;
ErrorStr="Cannot be Obsolete and In Price List";
}
else
{
Valid=true;
}
var stringB = /(obsnull|obs)/g;
var stringC = /,obs,/;
var stringA = (Values('fstk_product_type'));
if ((stringB.test(stringA)) && (Values('fstk_inpricelist'))= true)
{
Valid=false;
ErrorStr="Cannot be Obsolete and In Price List";
}
else
{
Valid=true;
}
Can anyone see what’s going wrong here please?
Thanks