vscode-apimanagement icon indicating copy to clipboard operation
vscode-apimanagement copied to clipboard

set-variable using C# Code not Colour Coded Correctly after Escaping Double Quotes

Open WarrenKinley opened this issue 7 months ago • 0 comments

The problem starts here when I am escaping the double quote:

Image

Set Variable policy:

<set-variable name="queryString" value="@{
			string returnValue = string.Empty;
            // Add query
            string searchQuery = string.Empty;
            if (false == string.IsNullOrEmpty(searchQuery))
            {
                returnValue += "&q=" + searchQuery;
            }
            // Add finder
            string finder = string.Empty;
			if (false == string.IsNullOrWhiteSpace(context.Variables.GetValueOrDefault<string>("customerAccountNumber")))
            {
                if (false == string.IsNullOrEmpty(finder)) { finder += ","; }
				finder += "BillToCustomerNumber=\"" + context.Variables.GetValueOrDefault<string>("customerAccountNumber") + "\"";
            }
            if (false == string.IsNullOrWhiteSpace(context.Variables.GetValueOrDefault<string>("transactionType")))
            {
                if (!string.IsNullOrEmpty(finder)) { finder += ","; }
				finder += "TransactionType=\"" + context.Variables.GetValueOrDefault<string>("transactionType") + "\"";
            }
            if (false == string.IsNullOrEmpty(finder))
            {
                if (false == string.IsNullOrEmpty(returnValue)) { returnValue += "&"; }
                returnValue += "finder=invoiceSearch;" + finder;
            }
            // Add only data
            if (false == string.IsNullOrEmpty(returnValue)) { returnValue += "&"; }
            if (false == string.IsNullOrWhiteSpace(context.Variables.GetValueOrDefault<string>("onlyData")))
            {
				returnValue += "onlyData=" + context.Variables.GetValueOrDefault<string>("onlyData");
            }
            else
            {
                returnValue += "onlyData=true";
            }
            // Add limit
            if (false == string.IsNullOrEmpty(returnValue)) { returnValue += "&"; }
            if (false == string.IsNullOrWhiteSpace(context.Variables.GetValueOrDefault<string>("limit")))
            {
				returnValue += "limit=" + context.Variables.GetValueOrDefault<string>("limit");
            }
            else
            {
                returnValue += "limit=500";
            }
            // Add fields
            if (false == string.IsNullOrEmpty(returnValue)) { returnValue += "&"; }
            if (false == string.IsNullOrWhiteSpace(context.Variables.GetValueOrDefault<string>("fields")))
            {
				returnValue += "fields=" + context.Variables.GetValueOrDefault<string>("fields");
            }
            else
            {
                returnValue += "fields=BillToCustomerNumber,CustomerTransactionId,TransactionType,DueDate,InvoiceCurrencyCode,TransactionNumber,TransactionDate,BillToSite,EnteredAmount,InvoiceBalanceAmount;receivablesInvoiceInstallments:InstallmentId,InstallmentSequenceNumber,InstallmentDueDate,OriginalAmount,PaymentDaysLate,InstallmentBalanceDue,InstallmentStatus,AccountedBalanceDue,InstallmentAmountAdjusted,InstallmentLineAmountOriginal,InstallmentLineAmountDue";
            }
            // Add expand
            if (false == string.IsNullOrEmpty(returnValue)) { returnValue += "&"; }
            if (false == string.IsNullOrWhiteSpace(context.Variables.GetValueOrDefault<string>("expand")))
            {
				returnValue += "expand=" + context.Variables.GetValueOrDefault<string>("expand");
            }
            else
            {
                returnValue += "expand=receivablesInvoiceInstallments";
            }
			return returnValue;
        }" />

WarrenKinley avatar Sep 10 '25 14:09 WarrenKinley