and more in a single search tool across platforms. Read the announcement here. |
02/13/2023 11:03 AM
Good Afternoon,
We are attempting to make use of the #CONST# syntax within the rest connector to populate the account type value based on the value of an attribute returned by the API Call.
Our colsToPropsMap within the ImportAccountEntJSON associated with the REST connector looks something like the follows. Please note that non-relevant properties have been stripped from the example below as the issue is only with recon of this specific property.
"colsToPropsMap": {
"accounttype": "#CONST#${response.profile.service_user == true ? 'Service Account': '' }~#~char"
}
And if we inspect the accounts, this is what we see for the accounttype for accounts within the endpoint:
And so, if we try to update the colsToPropsMap with the following:
"colsToPropsMap": {
"accounttype": "#CONST#~#~char"
}
If we inspect the accounts, this is what we see for the accounttype for accounts within the endpoint:
However, if we try to update the colsToPropsMap with the following:
"colsToPropsMap": {
"accounttype": "#CONST#${response.profile.service_user == true ? 'Service Account': 'User Account' }~#~char"
}
If we inspect the accounts, this is what we see for the accounttype for accounts within the endpoint:
And so, essentially what we are looking for is a solution or an alternative approach where if this property "response.profile.service_user" is true, then the accounttype attribute is set as 'Service Account', and in all other cases it is not set at all, and essentially blank, much like the first 3 accounts marked SFIS in the last screenshot. It appears that the issue is with the #CONST# syntax itself, as our second test case where we use the #CONST# syntax without a value contained within it should behave the same as an empty string would, and in this case we also see the literal string null being returned.
Any help that you can provide would be much appreciated. The goal of this approach is to ensure that this integration is consistent with what we have done in our past integrations, and as such we would like to avoid the use of a workaround like having to populate that field with a value such as 'User Account'.
Thanks,
Kyle Mlynarski
02/13/2023 12:23 PM
@Kmlynars - Did you try null instead of empty string?
"colsToPropsMap": {
"accounttype": "#CONST#${response.profile.service_user == true ? 'Service Account': null }~#~char"
}
-Siva
02/13/2023 12:27 PM
Good Afternoon,
Thank you for your response. Yes we have tried returning null instead of an empty string. The result is the same as case 2 as described above.
Thanks,
Kyle Mlynarski
02/13/2023 12:52 PM - edited 02/13/2023 01:05 PM
Thanks @Kmlynars.
How about just having if condition?
"colsToPropsMap": {
"accounttype": "#CONST#${String acctType='Service Account'; if(response.profile.service_user == true){return acctType}}~#~char"
}
-Siva
02/13/2023 02:33 PM
Good Afternoon,
Thank you for your response. Simply having an if condition still results in the literal string null being returned, as shown below.
Thanks,
Kyle Mlynarski
02/13/2023 01:04 PM
Try below
"colsToPropsMap": {
"accounttype": "#CONST#${response.profile.service_user == true && 'Service Account'}~#~char"
}
02/13/2023 02:30 PM
Good Afternoon,
Thank you for your suggestion. The segment above yields the literal strings 'true' and 'false' for the account type field, ash shown below.
Thanks,
Kyle Mlynarski
02/13/2023 03:11 PM
"accounttype": "#CONST#${ if('true'.equals(response.profile.service_user == true && 'Service Account')){return 'Service Account'}else {return 'Shared Account'}}}~#~char"
02/14/2023 08:16 AM
Good Morning,
Thank you for your suggestion. The segment above yields 'Service Account}' for the account type field for all accounts, which is not what we are looking to accomplish. The field should be blank for non-service accounts, and be 'Service Account' for Service accounts.
However I believe that in addition to this issue, you have a mismatched number of curly braces in this code segment. I have included the updated code segment below:
"accounttype": "#CONST#${ if('true'.equals(response.profile.service_user == true && 'Service Account')){return 'Service Account'}else {return 'Shared Account'}}~#~char"
The above yields the following:
Thanks,
Kyle Mlynarski
02/14/2023 01:06 PM
"accounttype": "#CONST#${ if('true'.equals(response.profile.service_user == true && 'Service Account')){return 'Service Account'}else {return ''}}~#~char"
02/15/2023 10:10 AM
Good Afternoon,
Thank you for your suggestion. The segment above yields null for the account type field for all accounts, which is not what we are looking to accomplish. The field should be blank for non-service accounts, and be 'Service Account' for Service accounts.
Thanks,
Kyle Mlynarski