replace function | Community
Skip to main content
New Participant
September 13, 2017
Solved

replace function

  • September 13, 2017
  • 14 replies
  • 13653 views

Hi

I am trying to export data from recipient and another table using a workflow activity. When i export I have to build a URL which requires names to be concatenate . also when the names have space or dashes I need to remove those. 

can someone help with javascript function or any build in expression that I can use to do that?

Example would be

Jane Smith  convert to JaneSmith

John-doe convert to  johndoe

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Amit_Kumar

Hi,

Use below and it should fix your problem.

<?xml version="1.0" encoding='ISO-8859-1' ?> 

<!-- =========================================================================== 

  Additional SQL functions for Adobe Campaign 

  ========================================================================== --> 

<package 

  namespace   = "vip" 

  name        = "Vip-additional-functions" 

  label       = "Vip Additional functions" 

  buildVersion= "6.1" 

  buildNumber = "8691"> 

 

 

<entities schema="xtk:funcList"> 

<funcList name="VIPFunctionList" namespace="vip"> 

<group name="string" label="String"> 

<function name="VIPReplace" type="string" args="(&lt;String>,&lt;String>,&lt;String>)" help="Replace all occurrences in string of substring from with substring to" minArgs="3" maxArgs="3" display="Replace all occurrences in string of substring from with substring to"> 

<providerPart provider="PostgreSQL,MSSQL" body="replace($1,$2,coalesce($3,E''))"/> 

</function> 

</group> 

</funcList> 

</entities> 

</package>

14 replies

vraghav
Employee
September 14, 2017

This is because in version 6.1.1 Adobe Campaign doesn’t allow direct usage of custom SQ functions, we need to whitelist them first inside the xtk:funcList entity

Create a new option name “XtkPassUnknownSQLFunctionsToRDBMS” with type as “Integer” and value as “1”. Save it. Now execute the workflow and it should run absolutely fine. This option will enable you to bypass the SQL check that avoids injection of custom SQL function. It is a workaround.

If you wish to get your SQL function whitelisted you can contact Adobe Professional Services.

Regards,

Vipul

New Participant
September 14, 2017

HI Vipul. I implemented the function and when I try to call it on the expression editor ( appears there) it gives me the error below. I am admin on the system.

l

New Participant
September 14, 2017

Thanks Vipul

I will give it a try

Also as for the javascript function is there a way of doing it? practically the data that I am manipulating will be exported to an flat file and also will be used on the delivery( will build an personalized URL within delivery content)

Thanks for your help

vraghav
Employee
September 14, 2017

Hi,

There is no REPLACE function available as part of query editor in Campaign. You will have to create one of your own.

Please refer to the documentation Adding additional SQL functions

I have a package for you which you can use directly.

<?xml version="1.0" encoding='ISO-8859-1' ?>

<!-- ===========================================================================

  Additional SQL functions for Adobe Campaign

  ========================================================================== -->

<package

  namespace   = "vip"

  name        = "Vip-additional-functions"

  label       = "Vip Additional functions"

  buildVersion= "6.1"

  buildNumber = "8857">

<entities schema="xtk:funcList">

<funcList name="VIPFunctionList" namespace="vip">

<group name="string" label="String">

<function name="(example is here, you can change to the name you want : VIPReplace)" type="string" args="(&lt;LookIn&gt;,&lt;From&gt;,&lt;To&gt;)" help="Replace all occurrences in string of substring from with substring to" minArgs="3" maxArgs="3" display="Replace all occurrences in string of substring from with substring to">

<providerPart provider="PostgreSQL,MSSQL" body="replace($1,$2,$3)"/>

</function>

</group>

</funcList>

</entities>

</package>

Import it and then you will see the option inside expression editor for use.

You can then user the expression

VIPReplace(@firstName,"-","")+VIPReplace(@lastName,"-","")

Hope this helps.

Regards,
Vipul