Developer forum

Forum » Integration » Using the @Code option in scripting

Using the @Code option in scripting

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,
How is this scripting supposed to work when using code?

I see there is an explicit option: Code.
What is the actual syntax in this case? Should I still use @Code(data["AccessUserAddressActive"]?.ToString() + "abc") or just data["AccessUserAddressActive"]?.ToString() + "abc" ?
I am trying to use something like this: @Code(data["ProductNumber"].Split('-')[0]) but I keep getting:
2026-05-20 13:43:20.8436|DataIntegration|ERROR|Error: The source reader for the table: [EcomProducts] can not get a value for the column: [ERP_Company].
...
Stack:    at Dynamicweb.DataIntegration.Providers.EcomProvider.EcomDestinationWriter.Write(Dictionary`2 row, Mapping mapping, Boolean discardDuplicates)    at Dynamicweb.DataIntegration.Providers.EcomProvider.EcomProvider.RunJob(Job job)
I am using DW10.23.13.
Thank you,
Adrian


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Adrian,

yes, you should still use:
@Code(data["AccessUserAddressActive"]?.ToString() + "abc")
and for the other sample you need to add .ToString():
@Code(data["ProductNumber"].ToString().Split('-')[0]) 

It looks like you need to check if there is a [ERP_Company] column in the mapping or schema.

BR, Dmitrij

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Dmitrij,
Sure, IU added the .ToString(0 in my attempt.
The column exists in the schema becuase I could load it:



But I still got the same error.
Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Dmitrij,
Apparently, I need to provide a source column even if I use the @Code option.
Adrian

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Dmitriy,

 

Is this something that can be improved? Having to pick a random source column seems odd. I'm experiencing the same thing, where I want to set constants to mappings and I naturally did not pick a source column (because it didn't make sense to me to do so)

 

BR,

Nuno Aguiar

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Nuno,
it was already fixed in the #27054. The problem is that is not merged to 10.23 but it is already available in the 10.24.14.
Could you try to upgrade and check if the problem is solved?
BR, Dmitrij

 

You must be logged in to post in the forum