Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards

Javascript functions in expression editor to assign a value in new variable/column

Avatar

Level 2

Hello All

 

I am trying to dynamically assign a value in the query parameter to a new variable using an existing column value. 

For example, if the column value is 50001 then the new variable value should be 50000, if the existing column value is 600032 then the variable value should be 600000. 
   cid      =       did
20023    =      20000
30056    =      30000
1200001 = 1200000

sharma_nik_0-1740153097077.png

I am able to get the required value in JS like this:
var dId = 10012;
var cId = Math.pow(10, (dId.toString().length - 2)) * parseInt(dId.toString().slice(0, 2));

but I am not able to use this function in Query activity's expression editor with something like this

sharma_nik_1-1740153241134.png


Is there any way I can acheive this??? Please help!

 

Thanks in advance...

 

Topics

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

4 Replies

Avatar

Community Advisor

Hi @sharma_nik ,

Consider you have a column @dId in the query, add an enrichment next to the Query activity and have the below expression,

POWER(10,Length(ToString(@dId))-2)*ToInteger(Substring(ToString(@dId),0,3 ))

POWER(10,Length(ToString(@dId))-2)*ToInteger(Substring(ToString(@dId),0,3 ))

ParthaSarathy_0-1740158769946.png

Avatar

Level 2

Hi Partha

Thanks for the response. Tried your solution, but getting following error:

 

 XTK-170016 You are not authorized to use SQL expressions. 'POWER' cannot be processed.

sharma_nik_0-1740483020602.png

 



Avatar

Community Advisor

Open Expression editor and paste it,

ParthaSarathy_0-1740574615585.png

Still If you face the error 'Power()' function is not available in your database function list. So ask your DB team to create it or from adobe campaign console create a power() function in /Administration/Configuration/SQL scripts/ and execute the SQL script. Disconnect and reconnect the console and paste the expression in Query editor and try it.

Avatar

Level 2

Hi Partha

 

Would you be able to provide the power() function script which I need to run into the sql script?

Thanks

Nikhil