Expand my Community achievements bar.

Your voice matters! Help shape the future of Adobe Journey Optimizer by sharing your feedback.
SOLVED

Replace an empty string with N/A in journey

Avatar

Level 2

We are trying to do a replace of an empty attribute in the client profile with N/A in a custom action in a journey.  We tried replace and replaceAll but neither gave us the solution we needed.

REPLACE

concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(replace(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName},'','NA'), ' ')
, replace(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName},'', 'NA') )
        , ' is customer since ' )
        , replace(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.customerSinceDate}),'','NA'))
        , ' has home at ')
        , replace(#{ExperiencePlatform.ProfileFieldGroup.profile..homeName}, '', 'NA'))
        , ' has potential total assets of ')
        , replace(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount}), '', 'NA'))
        , ' has active acct ending with ')
        , replace(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX'
and #{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).accountType}=='XXX'
and (in(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).acctLast4}, '', 'NA'))
        , ' opened on ')
        , replace(toString(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.at(0).productCode}=='XXX'
and #{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountType}=='XXX'
and (in(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).accountOpenDate}), '', 'NA'))
OUTPUT - Putting NA in from of everything
NATEST NATEST is customer since NA2023-12-13has home at NAHUBER HEIGHTS has potential total assets of NA67235 has active acct ending with NA7352 opened on NA2023-12-13
        
REPLACE ALL - Putting NA over and over
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(
concat(replaceAll(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName},'','NA'), ' ')
, replaceAll(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName},'', 'NA') )
        , ' is customer since ' )
        , replaceAll(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.customerSinceDate}),'','NA'))
        , ' has home at ')
        , replaceAll(#{ExperiencePlatform.ProfileFieldGroup.profile..homeName}, '', 'NA'))
        , ' has potential total assets of ')
        , replaceAll(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount}), '', 'NA'))
        , ' has active acct ending with ')
        , replaceAll(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX'
and #{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).accountType}=='XXX'
and (in(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).acctLast4}, '', 'NA'))
        , ' opened on ')
        , replaceAll(toString(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.at(0).productCode}=='XXX'
and #{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountType}=='XXX'
and (in(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).accountOpenDate}), '', 'NA'))
 
OUTPUT
NADNAANARNARNAENALNA NASNATNARNAINACNAKNALNAINANNAGNA is customer since NA2NA0NA2NA3NA-NA1NA2NA-NA2NA1NA has home at NAWNAENASNATNA NAHNAANARNATNAFNAONARNADNA NABNARNAANANNACNAHNA has potential total assets of NA7NA3NA6NA1NA5NA6NA has active acct ending with NA8NA3NA5NA7NA opened on NA2NA0NA2NA3NA-NA1NA2NA-NA2NA1NA
        
        
Would like the output to looking like this        
JOHN SMITH is customer since 2023-12-18 has home at WEST TUSC has potential total assets of N/A has active account ending with 1234 opened on 2023-12-19
        
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

replace --> replace the first occurence while replaceAll --> replaces all occurences

 

OUTPUT - Putting NA in front of first occurence (firstname --> TEST)
NATEST NATEST is customer since NA2023-12-13has home at NAHUBER HEIGHTS has potential total assets of NA67235 has active acct ending with NA7352 opened on NA2023-12-13
 
OUTPUT - Putting NA in front of first occurence (firstname --> DARREL)
NADNAANARNARNAENALNA NASNATNARNAINACNAKNALNAINANNAGNA is customer since NA2NA0NA2NA3NA-NA1NA2NA-NA2NA1NA has home at NAWNAENASNATNA NAHNAANARNATNAFNAONARNADNA NABNARNAANANNACNAHNA has potential total assets of NA7NA3NA6NA1NA5NA6NA has active acct ending with NA8NA3NA5NA7NA opened on NA2NA0NA2NA3NA-NA1NA2NA-NA2NA1NA

 

Try this 

 

#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount}, defaultValue : "NA"}

 

 

Note: The type of the field and the default value must be the same. 

David



David Kangni

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

replace --> replace the first occurence while replaceAll --> replaces all occurences

 

OUTPUT - Putting NA in front of first occurence (firstname --> TEST)
NATEST NATEST is customer since NA2023-12-13has home at NAHUBER HEIGHTS has potential total assets of NA67235 has active acct ending with NA7352 opened on NA2023-12-13
 
OUTPUT - Putting NA in front of first occurence (firstname --> DARREL)
NADNAANARNARNAENALNA NASNATNARNAINACNAKNALNAINANNAGNA is customer since NA2NA0NA2NA3NA-NA1NA2NA-NA2NA1NA has home at NAWNAENASNATNA NAHNAANARNATNAFNAONARNADNA NABNARNAANANNACNAHNA has potential total assets of NA7NA3NA6NA1NA5NA6NA has active acct ending with NA8NA3NA5NA7NA opened on NA2NA0NA2NA3NA-NA1NA2NA-NA2NA1NA

 

Try this 

 

#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount}, defaultValue : "NA"}

 

 

Note: The type of the field and the default value must be the same. 

David



David Kangni

Avatar

Level 4

Hey @Rochelle_Satow you should be handling the null/empty BEFORE you try to do the concatination.
Try this with the coalesce function handling this logic before it gets concatenated into the string.

concat(
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName}, 'N/A'), ' ',
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName}, 'N/A'), ' is customer since ',
coalesce(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.customerSinceDate}), 'N/A'), ' has home at ',
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile..homeName}, 'N/A'), ' has potential total assets of ',
coalesce(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount}), 'N/A'), ' has active acct ending with ',
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX' and #{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).accountType}=='XXX' and (in(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).acctLast4}, 'N/A'), ' opened on ',
coalesce(toString(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX' and #{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountType}=='XXX' and (in(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).accountOpenDate}), 'N/A')
)


Additionally, you can tweak it to the following for a couple additional reasons.

iif(
not(
#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName} or
#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName} or
#{ExperiencePlatform.ProfileFieldGroup.profile.customerSinceDate} or
#{ExperiencePlatform.ProfileFieldGroup.profile..homeName} or
#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount} or
(
#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(
#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX' and
#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).accountType}=='XXX' and
(in(#{ExperiencePlatform.ProfileFieldGroup.profile..accounts.at(0).accountStatusCode}, ['A', 'N']))
).at(0).acctLast4} and
#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(
#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX' and
#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountType}=='XXX' and
(in(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountStatusCode}, ['A', 'N']))
).at(0).accountOpenDate}
)
),
null, // Return null if all are empty/null
concat(
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.firstName}, 'N/A'), ' ',
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile.person.name.lastName}, 'N/A'), ' is customer since ',
coalesce(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.customerSinceDate}), 'N/A'), ' has home at ',
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile..homeName}, 'N/A'), ' has potential total assets of ',
coalesce(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.TotalAssetAmount}), 'N/A'), ' has active acct ending with ',
coalesce(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX' and #{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).accountType}=='XXX' and (in(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).acctLast4}, 'N/A'), ' opened on ',
coalesce(toString(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.all(#{ExperiencePlatform.ProfileFieldGroup.profile._accounts.at(0).productCode}=='XXX' and #{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountType}=='XXX' and (in(#{ExperiencePlatform.ProfileFieldGroup.profile.accounts.at(0).accountStatusCode}, ['A', 'N']))).at(0).accountOpenDate}), 'N/A')
)
)

This way, you can handle the all null scenario independantly of the other solution, making it less prone to errors stemming from individual string mistakes. (Or just letting you skip it entirely, if that's your intent for an all N/A scenario )

Let me know if this solves your problem, or if you have any other questions.

Best,
Tyler