I am trying to make an order counter for Delivery entity types. I slightly customized the original Order number tutorial but my issue is combining two strings together to pull the value out.
function concatString(stringA,stringB,stringC,stringD){
var r = "";
r = r.concat(stringA,stringB,stringC,stringD);
Data.Set('GlobalFoob Order No',r);
return
}
Something like that and use it like an update setting action rather than to get the value to save.
I see what you mean but technically r is the result of the concatString function.
function concatString("{ENITY NAME:Delivery}"," Order No")
{
var r = "";
var rv = "";
r = r.concat(stringA,stringB); r in this scenario would be "GlobalFood Order No"
rv = rv + 1;
Data.Set(r,rv);
return rv;
}
So - if I am doing it this way, does that mean I would have to always add +1 to whatever my value is? Wouldn’t this require a query of rv (program setting value) first?
Ive been at this all day, I am kind of losing my focus here but I appreciate your input
Okay, so you’re trying to retrieve a global setting. Why not update the entity with a field like ‘Order Count’?
So here’s where I’m at (I renamed the function as it’ll be single-use):
function orderNoString(stringA)
{
var tail = " Order No"
var r = "";
r = r.concat(stringA,tail);
return r;
}
To get the program setting value you would then use {SETTING:{CALL:concat.orderNoSetting('{ENITY NAME:Delivery}')}}
or you can return the program setting directly:
function orderNoSetting(stringA)
{
var tail = " Order No";
var settingName = "";
settingName = settingName.concat(stringA,tail);
var json = gql.Exec('query{getGlobalSetting(name:"'+settingName+'"){name,value}}');
var obj = JSON.parse(json);
var r = obj.data.getGlobalSetting.value;
return r;
}
and {CALL:concat.orderNoSetting('{ENTITY NAME:Delivery}')} will return the setting value
Wow, thats one way to do it! I solved my problem with that simple SQL query though and printing template wasn’t much of a stickler for two variables like
{TICKET TAG:{ENTITY NAME} Order No}
Very likely community will find this useful in the future.