str salesStatusValue = ‘Open order’;
salesStatus = str2Enum(salesStatus,salesStatusValue);
str salesStatusValue = ‘Open order’;
salesStatus = str2Enum(salesStatus,salesStatusValue);
public void findOrcreatePostalAddress(
LogisticsAddressStreet _street,
str _countryRegionCode,
str _city,
str _state,
str _postalCode,
LogisticsDescription _locationName,
PurchTable _purchTable)
{
LogisticsPostalAddress postalAddress;
DirPartyLocation partyLocation;
DirPartyPostalAddressView dirPartyPostalAddressView;
DirParty dirParty;
CompanyInfo companyInfo = CompanyInfo::findDataArea("USMF"); // Get company info for legal entity
// Try to find an existing postal address for this company with given parameters
select firstonly dirPartyPostalAddressView
where dirPartyPostalAddressView.Party == companyInfo.RecId
&& dirPartyPostalAddressView.LocationName == _locationName
&& dirPartyPostalAddressView.Street == _street
&& dirPartyPostalAddressView.City == _city
&& dirPartyPostalAddressView.State == _state
&& dirPartyPostalAddressView.CountryRegionId == _countryRegionCode;
// If no existing postal address found, create a new one
if (!dirPartyPostalAddressView)
{
// Construct DirParty from the company
dirParty = DirParty::constructFromCommon(companyInfo);
// Define location role container (e.g., Delivery)
container roleContainer = [LogisticsLocationRole::findByType(LogisticsLocationRoleType::Delivery).RecId];
// Set postal address details
dirPartyPostalAddressView.Street = _street;
dirPartyPostalAddressView.City = _city;
dirPartyPostalAddressView.CountryRegionId = _countryRegionCode;
dirPartyPostalAddressView.State = _state;
dirPartyPostalAddressView.ZipCode = _postalCode;
dirPartyPostalAddressView.IsPrimary = NoYes::No;
dirPartyPostalAddressView.LocationName = _locationName;
// Create or update the postal address in D365FO
dirPartyPostalAddressView = dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView, roleContainer);
}
}
[ExtensionOf(classStr(SrsReportRunPrinter))]
final class TestSrsReportRunPrinter_Extension
{
public void printReport()
{
if (reportContract.parmRdpName() == "SalesInvoiceDP")
{
SalesInvoiceContract salesInvoicecontract = reportContract.parmRdpContract() as SalesInvoiceContract;
printSettings.reportTitle("SalesInvoice");
printSettings.custInvoiceRecid(salesInvoicecontract.parmRecordId());
}
next printReport();
}
}
[ExtensionOf(classStr(SRSPrintDestinationSettings))]
final class TestSRSPrintDestinationSettings_Extension
{
internal str reportTitle, clreportTitle;
internal RecId custJourRecId;
[DataMemberAttribute]
public str reportTitle(str _reportTitle = reportTitle)
{
reportTitle = _reportTitle;
return reportTitle;
}
[DataMemberAttribute]
public RecId custInvoiceRecid(RecId _custJourRecId = custJourRecId)
{
custJourRecId = _custJourRecId;
return custJourRecId;
}
public SrsReportEMailDataContract parmEMailContract(SrsReportEMailDataContract _emailContract)
{
contract = next parmEMailContract(_emailContract);
if (this.reportTitle() == "SalesInvoice")
{
CustInvoiceJour custinvoicejour;
select firstonly custinvoicejour where custinvoicejour.RecId == this.custInvoiceRecid();
contract.parmTo(custinvoicejour.TestExternalRequesterEmail);
emailSubject = contract.parmSubject();
emailSubject = strReplace(emailSubject, "%PurchaseOrder%", purchTable.PurchId);
contract.parmSubject(emailSubject);
}
return contract;
}
}
str base64String = "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzCi9LaWRzIFsgMyAwIFIgXQovQ291bnQgMSA+PgplbmRvYmoKMyAwIG9iago8PCAvVHlwZSAvUGFnZQovUGFyZW50IDIgMCBSCi9NZWRpYUJveCBbMCAwIDYxMiA3OTJdCi9Db250ZW50cyA0IDAgUgovUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiA+PgplbmRvYmoKNCAwIG9iago8PCAvTGVuZ3RoIDQ0ID4+CnN0cmVhbQpCVAovRjEgMjQgVGYKMTAwIDcwMCBUZAooSGVsbG8gV29ybGQpIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udAovU3VidHlwZSAvVHlwZTEKL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZgowMDAwMDAwMDEwIDAwMDAwIG4KMDAwMDAwMDA3OSAwMDAwMCBuCjAwMDAwMDAxNzggMDAwMDAgbgowMDAwMDAwMzAxIDAwMDAwIG4KMDAwMDAwMDM5MCAwMDAwMCBuCnRyYWlsZXIKPDwgL1NpemUgNgovUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNTAyCiUlRU9G";
str fileName = "MyAttachment.pdf";
str fileType = "PDF";
PurchTable purchTable;
select firstOnly purchTable where purchTable.PurchId == 'PO00003075';
if (purchTable)
{
System.IO.MemoryStream memoryStream;
DocuRef docuRef;
#define.File('File')
try
{
if(purchTable.RecId && fileName)
{
docuRef.clear();
docuRef.RefTableId = purchTable.TableId;
docuRef.RefRecId = purchTable.RecId;
docuRef.RefCompanyId = curExt();
docuRef.TypeId = #File;
docuRef.Name = System.IO.Path::GetFileNameWithoutExtension(fileName);
docuRef.DocumentId = newGuid();
if(docuRef.validateWrite())
{
docuRef.insert();
memoryStream = new System.IO.MemoryStream(System.Convert::FromBase64String(base64String));
if(memoryStream != null)
{
using(System.IO.MemoryStream fileStream = memoryStream)
{
DocuAction action = docuRef.docuAction();
action.attachFile(docuRef,fileName,'',fileStream);
info(strFmt('File is uploaded to Sales ID:%1 successfully',salesTable.SalesId));
}
}
}
}
}
catch(Exception::CLRError)
{
System.Exception e = CLRInterop::getLastException();
if(e != null)
{
e = e.InnerException;
throw error(e.ToString());
}
}
}
else
{
warning("Purchase Order not found.");
}
System.Net.HttpWebRequest request; System.Net.HttpWebResponse response; System.IO.Stream dataStream; System.IO.StreamReade...