Share via


How to avoid duplicate string concatenation in X++ Dynamics AX 2012 R2

Yesterday one of my colleague was facing duplicate string concatenation issue need to avoid duplicate string concatenation.

Problem:

Need to show bill of lading numbers for invoices against a specific Sales order, in this case we were facing duplicate BOLs issue that was being shown on report header

Situation:

To avoid the duplication of BOLs in concatenated string we have used the string function “strScan” that take the string variable in which we are trying to concat the All BOLs that need to be populated on report header and the current BOL that is being concate with string .

Following code is used to avoid duplicate concatenation of string:
   

if(!strScan(billOfLading, pickInHeader.BillOfLading,1,strLen(billOfLading)))
{

       billOfLading += #Comma + pickInHeader.kwdBillOfLading;
}

Note: The string function “strScan” only works with same length of string concatenation