Unable to utilize $msdynamics Velocity macro with integer types

Good morning everyone!

We are trying to set up a custom Dynamics action to get contacts via phone number and whether they're active or not. This requires the use of two separate filters, and we've had a couple struggles with this. We've worked around them, but want to know if there's a better option for each of our workarounds.

  1. We are trying to use $msdynamics.fieldSearchFilter() to convert an input value to a search parameter. The input type is an Integer in the contract, and the Dynamics server expects an Integer as well. However, when the macro is parsed, it's converting the value to a String. The field we're trying to filter is an integer type, and due to the macro converting it to a separate type, Dynamics is complaining about comparing a string to an int. We've had to manually enter the filter by writing $esc.uriEncode("statecode eq $input.STATE_CODE"), but we don't particularly like this because we're having to write the query manually instead of having the $msdynamics macro do it for us, which can be annoying down the line if we need to compare multiple int values at the same time and are having to rewrite the same statement over and over. Surely there is a better way to do this? Some screenshots to explain this better are below.
    image
    image
    image

  2. This isn't really an issue, but just wanted some advice. We have to use and to concatenate two filters together. To do this we're just manually typing in %20and%20 into the URL parameter. I don't really like this too much, but not sure if there's a better way to do this as well.

Here is what our current Request URL Template looks like, if anyone could give us some pointers that'd be great, thanks!!

/api/data/v9.2/contacts?${esc.dollar}select=[REDACTED]&${esc.d}filter=$esc.uriEncode("statecode eq $input.STATE_CODE")%20and%20($esc.uriEncode($msdynamics.phoneNumberFilter("$input.PHONE_NUMBER", ["telephone1", "telephone2", "telephone3", "mobilephone"])))

Hey Nate,

I took a look at the code for #1. You are correct that this currently can only handle string types. Please enter an idea for supporting numeric types: Genesys Cloud Ideas Portal

For #2 it can be cleaned up a bit by moving the " and " inside of the uriEncode like this:

/api/data/v9.2/contacts?${esc.dollar}select=[REDACTED]&${esc.d}filter=$esc.uriEncode("statecode eq $input.STATE_CODE and ")($esc.uriEncode($msdynamics.phoneNumberFilter("$input.PHONE_NUMBER", ["telephone1", "telephone2", "telephone3", "mobilephone"])))

Trying to get it down to 1 uriencode has been a challenge though.

--Jason

1 Like

/api/data/v9.2/contacts?${esc.dollar}select=[REDACTED]&${esc.d}filter=$esc.uriEncode("statecode eq $input.STATE_CODE and ("+$msdynamics.phoneNumberFilter("$input.PHONE_NUMBER", ["telephone1", "telephone2", "telephone3", "mobilephone"])))

That provides almost exactly the same output as the original, however it will URI encode the '(' after the 'and', so it might not actually work. This was pretty tricky to work with, so I would probably stick with the version in my previous post.

--Jason

1 Like

Thanks for the suggestions! I'll submit an idea on the Ideas Portal now, and take what you said to my team for further review. Again, much appreciated :smile:

For anyone coming here looking for the solution to the same problem I had, an idea was submitted here for supporting Integers in that macro.