Hey,
I am trying to generate quote/order confirmation documents using CRMScript. I just can't seem to format the dates correctly.
A code snippet of the document generation:
NSQuotePublishDocuments saveQuoteDocs(Integer quoteVersionId, Bool isOrderConfirmation){
NSQuoteAgent qa;
DateTime timeNow = getCurrentDateTime();
DateTime expiryDate = getCurrentDateTime().addDay(expiryDateDays);
DateTime followupDate = getCurrentDateTime().addDay(followUpDateDays);
followupDate.addHour(followUpDateHours);
NSQuoteEntity qEntity = qa.GetQuoteEntityFromSaleId(ed.getInputValue("ActiveSaleId").toInteger());
qEntity.SetPreferredEmailCulture(quoteCulture);
qa.SaveQuoteEntity(qEntity);
NSQuotePublishDocuments docs;
if(isOrderConfirmation) {
docs = qa.GenerateQuoteDocuments(quoteVersionId, orderTemplateEmailId, true, getOrderDocTmplId(), true, orderSubjectTextEmail);
} else {
qa.SendQuoteVersion(quoteVersionId, expiryDate, followupDate, followUpText, quoteCulture);
docs = qa.GenerateQuoteDocuments(quoteVersionId, quoteTemplateEmailId, true, getQuoteDocTmplId(), true, quoteSubjectTextEmail);
}
return docs;
}
If saveQuoteDocs should generate an orderconfirmation, the following line has also been executed:
qAgent.PlaceOrder(qAlternative.GetQuoteAlternativeId(), markAsSold, poNum, orderComment, culture);
The code generates a document and substitutes all of the template variables like it should, except for the dates.
No matter what i try, dates remain on the MM/dd/yyyy format. I need it to be on a danish format (dd-MM-yyyy).
I have tried passing both "da", "DA", "da-DK", "DK", "dk" and "" as the culture argument to the PlaceOrder and SendQuoteVersion functions. I have tried adding the mergefield "Culture:da-DK" to the template itself as well. I noticed during testing, that the mergefield "Culture:" actually succeded in changing the format of numbers like the salesprice of a quoteline (e.g "Culture:en-US" = 1,234.20 ... "Culture:da-DK" = 1.234,20) , yet dates like {sdat}, {sada} remain unchanged.
If i use the normal quote dialog option of "show confirmation" through the ui to generate the document, everything works correctly.
I might very well have overlooked something obvious, and if so... Please enlighten me! I am running out of ideas. Help is very much appreciated :D
Alle Svar (1)
Hi,
The issue is here that you can't provide the culture that is used to format values in the API call directly, CRM.Web controls this using these HTTP headers;
But you can't set those when doing an NetServer API call from CRMScript.
Note that the behavior to how the culture is applied is a bit weird, see bug: https://community.superoffice.com/en/product-releases/bugs-wishes/product-issue/?bid=74361&azure=1