Order Number Counter per Entity


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.

What would be the correct syntax to pull that value out?

{:{ENTITY NAME:Delivery} Order No}
[=string.concat("{ENTITY NAME:Delivery}"," Order No}")]
[=CONCATENATE("{:{ENTITY NAME:Delivery}"," Order No}")]

I ran into the same issue a while back and couldn’t get anything to work. So now I use a script for that:

function concatString(stringA,stringB)
  var r = "";
  r = r.concat(stringA,stringB);
  return r;

Thanks @Memo,

I might need a bit of guidance. I am calling the script but not sure whether I am putting in strings correctly because all I get is ')} as an output.


function concatString(stringA,stringB,stringC,stringD)
  var r = "";
  r = r.concat(stringA,stringB,stringC,stringD);
  return r;

{CALL:concat.concatString('{:','{ENTITY NAME:Delivery}','Order No','}')}

So I played around and managed to get the correct concatString but now it literally tags it with result instead of pulling that setting number

However, when I use that exact result it gives me a setting number.

I am so confused :sweat_smile:

Don’t return the call for the setting value, just return the value itself, there are helper functions formprogram settings…

Thanks @JTRTech, but I am not sure how to do that, maybe I am just overthinking it…

Something like this?

[=Data.Get('{CALL:concat.concatString("{",":","{ENTITY NAME:Delivery}"," Order No","}")}')]

No, within the script;

function concatString(stringA,stringB,stringC,stringD){
  var r = "";
  r = r.concat(stringA,stringB,stringC,stringD);
  Data.Set('GlobalFoob Order No',r);

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;
  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 :sweat_smile:

Oh right, yes.
So your concat is name and counter is value.
So yiu would need to do data get r ass one then set r with rv

After frustrating long day & loads of overthinking I just thought why not pull it through SQL once its already saved… F*** me… :sweat_smile:

{REPORT SQL DETAILS:SELECT [Value] FROM [ProgramSettingValues] WHERE [Name]='{ENTITY NAME:Delivery} Order No':F.Value}

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

1 Like

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


Very likely community will find this useful in the future.

Good work @Memo!

1 Like