Solved

Parametrized template error due to XML in the code

  • 11 October 2023
  • 2 replies
  • 48 views

Userlevel 2
Badge +5

Hi, 

We use often code with XML in our templates, like for processing the response of an SOAP API or using multirow parameter.
Then we have the square brackets in the code, like what also is needed for parametrized template.

When we make changes in the code and save it, then the error below is popping up in the Deploy tab.

For now we copy the code and apply the changes in the related template and then we need to generate the control procedure again before deploying it, but that is lot of extra work.

We are using the TW 2023.2.12 release. 

Is there a better solution for this or can the interpretation of the code being improved that it is coming from XML?

icon

Best answer by Erwin Ekkel 11 December 2023, 10:53

View original

2 replies

Userlevel 6
Badge +16

A different customer reported this problem recently. We are investigating this how to best resolve this. We will keep you posted. 

Userlevel 6
Badge +16

We have inspected the ticket and came to the conclusion that this is the intended behavior. The Software Factory uses the bracket convention to identity parameters used in code. As there are many alternatives, which are listed below.
 
Some alternatives you can apply:
·You can use the following function to add brackets around parts of your code: QUOTENAME (Transact-SQL) - SQL Server | Microsoft Learn
This will allow you to remove the literal brackets from your code and therefore allow you to edit the code via the Program object generated code field in Control procedure > Deploy.

Example:            
Before 
set @content_post='{ "channels":[ { "name":"MODELLO", "type":"STRING", "value":"'+cast(@po_id as varchar(50))+'"} ] }'
After
set @content_post='{ "channels":' + quotename(' { "name":"MODELLO", "type":"STRING", "value":"'+cast(@po_id as varchar(50))+'"} ') +' }'


 
·Placing the start and end brackets on different lines will prevent the Software Factory from seeing a parameter. This may be a better alternative for longer JSON-arrays.
 
I hope these alternatives are sufficient in solving the problem at hand.

Reply