Number and Date Formatting not working when using "NSQuoteAgent.GetOrderConfirmation"

lock
push_pin
done
Beantwortet
2

Hi,

You may have seen from a previous post (where I raised a question on document filename formats), that I have written a script that uses the "NSQuoteAgent.GetOrderConfirmation" function, to allow one of our customers to produce multple order documents against the same quote, but using different document templates for each document.

Our customer needs multiple templates against the quote, for things such as Works Order Sheet, Picking Form etc., and the "GetOrderConfirmation" function works really well, as it allows you to save in SuperOffice multiple "Order Confirmation" documents, using different "Order Confirmation" templates against the same quote.  Below is a screenshot of the script, that runs from the Sale Task menu.

The trouble is, that it does not seem to respect the user's Number and Date format when producing the document.

Below is a screenshot of part of an order confirmation document produced when raising the document in the normal manner (at the point of placing the order, which can only be done against one of the document templates for any given quote).  The date correctly shows in the UK date format, as per the customer's number and date format.

When I produce the same document via a CRM Script, using the following code.

    NSQuoteAgent quoteAgent;
    String quoteDoc = quoteAgent.GetOrderConfirmation(quoteVersionId, confirmationTemplateId);

This is the document it produces, with the user's number and date format being ignored.

As the script runs from the Sale Task menu, I expected the script to run in the context of the user, and therefore use the user's number and date format settings, but this seems not to be the case.

Am I missing something in my code, or is this a bug with the function in SuperOffice?

Many thanks,

Trevor

18 h, 20 m vor | 08:54 AM

Alle Antworten (2)

Hi,


See this thread: https://community.superoffice.com/en/forums/user-forums/general-crm/crmscript.-dates-in-quote-documents-does-not-format-correctly

 

18 h, 13 m vor | 09:01 AM
Thanks David,

This does look a bit complicated, is there any further documentation on manually calling the API using the HTTP class via a CRM Script?

Also do you know if there is a wish logged to be able set the culture directly via a CRM Script, so that this is not needed?

Many thanks,

Trevor
18 h, 4 m vor | 09:10 AM

Hi,

There is this bug registered;

https://community.superoffice.com/en/product-releases/bugs-wishes/product-issue/?bid=37238&azure=1

This does look a bit complicated, is there any further documentation on manually calling the API using the HTTP class via a CRM Script?

You can call the the API like this, but do note you need an application token/client secret of a app authorized on the specific tenant to generate a valid access token;

#setLanguageLevel 4;

NSUserAgent userAgent;

Struct GetOrderConfirmationArgs
{
    Integer QuoteVersionId;
    Integer ConfirmationTemplateId;
};

GetOrderConfirmationArgs args;
args.QuoteVersionId = 1;
args.ConfirmationTemplateId = 2;

// app token is required otherwise we can't call the Web API
String appToken = "";

String url = getProgramBlogic().until("CS/") + "api/v1/Agents/Quote/GetOrderConfirmation";

HTTP httpClass;
  
httpClass.addHeader("Accept", "application/json");
httpClass.addHeader("Content-Type", "application/json");

httpClass.addHeader("Authorization", "Bearer " + userAgent.GetAccessToken(appToken, true));

httpClass.setOption("parameters", "? " + args.toJsonString());  

// enable utf8 so that characters are send correctly
httpClass.setOption("parametersUTF8", "true");

NSStream responseAsStream = httpClass.postAsStream(url);
  
if (httpClass.hasError() == true || httpClass.getValue("statusCode").toInteger() != 200)
{
    String errorMessage = "HTTP class returned error: " + httpClass.getErrorMessage();
    errorMessage += "\r\nStatus code returned: " + httpClass.getValue("statusCode");
    errorMessage += "\r\nResponse: \r\n " + String(responseAsStream.GetStream());

    throw errorMessage;
}

String quoteDocumentContent = String(responseAsStream);
17 h, 44 m vor | 09:30 AM
Hi David,

Thank you for this, this is really helpful. I will give this a go tomorrow.

Thanks again for your help, really appreciated.

Trevor
17 h, 1 m vor | 10:14 AM

Antwort hinzufügen