Mapping Automation to Entity State

Script (Handler: PointsCalc, Function: ConvertPoints)

Handler: PointsCalc

    function ConvertPoints(Points) {
      var calc = Points/2;
      return '$'+Math.floor(calc).toFixed(2);
    }

Call tag;

{CALL:PointsCalc.ConvertPoints({ENTITY DATA:Customer:Points})}

5 gives $2.00

Take out the .toFixed(2) if you dont want the decimals.

2 Likes

Thanks @JTRTech - your obviously getting confident with Jscript! - Well its 1.49am here but I will push on, its worth it :smile:

1.57am and I am done!

Can now use that function and read up on Jscript so I can return unused remaining points on account.
Fantastic work :joy: Red Eyes must sleep :sleeping:

(Its getting additiveā€¦)

You should be able to use JScript functions in an expression, without needing a script {CALL:X}.

Something like this should work:

Convert Points\r$[=Math.floor(TN('{ENTITY DATA:Customer:Points}')/2).toFixed(2)]

Here, I replaced entity data with '7' to test, and it appears to workā€¦


That said, I am still a proponent of making function libraries and using CALL:X as @JTRTech has shown ā€¦ that way, all your code is in a single place.

2 Likes

@pauln can you confirm I have read that right, the verdict was buttons canā€™t be mapped to entity state and you had to use a ticket state rather than entity state?

We know that Order States work as well, correct? I mean, Void/Cancel and Gift/Cancel buttons work on Order State.

Not sure though if AMCs are Entity State awareā€¦ but not sure why they would be restricted from the State mappings. Might have to do with the fact that a Ticket can have multiple Entities assigned, so the State of which Entity Type to look at is the questionā€¦

Void/Cancel etc are only valid on order line mapped buttons.
Ticket states for ticket level buttons.
So under the impression entity states arenā€™t mappable on a button on ticket line, well I couldnā€™t get it to work and makes sense following that pattern.
Entity states are not listed like ticket states which is another thing suggesting that its not possible.

2 Likes

Yes correct assumption @JTRTech - sorry for the delay, extremely bogged down :persevere:
The issue is the MAPPINGS in my case, there is not State available for ENTITY as far as ā€œEnabledā€, ā€œVisibleā€ - it is all based on Ticket.

Had to crack open the Automation and digā€¦

1 Like