How can I read this constant value from table script?
Developer forum
E-mail notifications
Reading constant value in Table Script
Replies
Anything on this?
We are having two different mapping for each stock row. And I want to read the ProductLanguageId for each row via Table Script
Hi Jason,
you can read about that here. It is for DW9 but it works the same for the DW10.
The Table scripting selector drop-dnown is shown in the Table Mapping Edit screen dialog only when there is any custom TableScript class available. By default there is no custom TableScripts available in the standard Dynamicweb 10 solutiuon. Try to supply the implemented custom table script dll into the solution bin folder and select it in the Edit Table Mapping dialog.
BR, Dmitrij
I think what Jason is talking about is getting the value of a constant defined on the mapping inside a TableScript. Looks like he has the script working, but can't find the constant.
I don't think it's accessible as I could only find it in a non-public _columnMapping collection. I.e. with a mapping like this:
I could only find my constant value in mapping._columnMappings which is not public:
Maybe it's an option to expose the mappings as some kind of ReadOnly collection so we can interrogate these values without changing them?
Imar
Hi Imar,
yes, there is already a public API for that. To get all the column mappings you can call this public method:
var columnMappings = mapping.GetColumnMappings(false);
Once you find your constant column mapping from the returned collection then you can check if it has a script provider and its value:
bool hasScriptWithValue = columnMapping.HasScriptWithValue();
if (hasScriptWithValue)
{
string? scriptValue = columnMapping.GetScriptValue();
}
BR, Dmitrij
Hi Dmitrij
That works. Thank you !
You must be logged in to post in the forum