Wednesday, 30 August 2023
Download a xml file using Dynamics 365 to local folder
Hello All,
Today we are using a simple code to download a cml file to local folder using D365fo.I will skip all the steps where you create a xml file , because you can refer to number of blogs posts for this.
Here is sample code snippet for downloading xml file to local folder
File::SendStringAsFileToUser(XMLDoc, FileName);
Thanks,
Vivek Chirumamilla
Tuesday, 15 August 2023
Table Modified field using coc in D365fo
///
/// Extension of LedgerJournalTable
///
[ExtensionOf(tableStr(LedgerJournalTable))]
final class SCA_FS_LedgerJournalTable_Extension
{
///
/// Proccess the modified field events for LedgerJounal trans
///
/// reference to fieldId
public void modifiedField(FieldId _fieldId)
{
next modifiedField(_fieldId);
if (_fieldId == fieldNum(LedgerJournalTable, testfield) && this.JournalType == LedgerJournalType::Payment)
{
//if(this.WorkflowApprovalStatus == LedgerJournalWFApprovalStatus::Approved || this.WorkflowApprovalStatus == LedgerJournalWFApprovalStatus::Rejected)
{
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
select firstonly RecId from workflowTrackingStatusTable
order by workflowTrackingStatusTable.CreatedDateTime desc
where workflowTrackingStatusTable.ContextRecId == this.RecId
join User from workflowTrackingTable
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission;
this.ReportedAsReadyBy = workflowTrackingTable.User;
//if(this.WorkflowApprovalStatus == LedgerJournalWFApprovalStatus::Approved)
{
select firstonly RecId from workflowTrackingStatusTable
order by workflowTrackingStatusTable.CreatedDateTime desc
where workflowTrackingStatusTable.ContextRecId == this.RecId
join User from workflowTrackingTable
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval;
this.Approver = HcmWorker::userId2Worker(workflowTrackingTable.User);
}
if(this.WorkflowApprovalStatus == LedgerJournalWFApprovalStatus::Rejected)
{
select firstonly RecId from workflowTrackingStatusTable
order by workflowTrackingStatusTable.CreatedDateTime desc
where workflowTrackingStatusTable.ContextRecId == this.RecId
join User from workflowTrackingTable
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Rejection;
this.RejectedBy = workflowTrackingTable.User;
}
}
}
}
}
Form Event Handler in D365fo
///
/// Event Hnadler Class For Ledger Journal Table Form
///
final class SCA_FS_LedgerJournalTableFormEventHandler
{
///
/// Approve Event For Approve
///
/// sender of event
/// Event Args
///
[FormControlEventHandler(formControlStr(LedgerJournalTable, Approve), FormControlEventType::Clicked)]
public static void Approve_OnClicked(FormControl sender, FormControlEventArgs e)
{
LedgerJournalTable journal = sender.formRun().dataSource('LedgerJournalTable').cursor();
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
select firstonly RecId from workflowTrackingStatusTable
order by workflowTrackingStatusTable.CreatedDateTime desc
where workflowTrackingStatusTable.ContextRecId == journal.RecId
join User from workflowTrackingTable
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission;
journal.ReportedAsReadyBy = workflowTrackingTable.User;
}
///
/// Reject Event For Reject
///
/// sender of event
/// Event Args
///
[FormControlEventHandler(formControlStr(LedgerJournalTable, Reject), FormControlEventType::Clicked)]
public static void Reject_OnClicked(FormControl sender, FormControlEventArgs e)
{
LedgerJournalTable journal = sender.formRun().dataSource('LedgerJournalTable').cursor();
WorkflowTrackingTable workflowTrackingTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
select firstonly RecId from workflowTrackingStatusTable
order by workflowTrackingStatusTable.CreatedDateTime desc
where workflowTrackingStatusTable.ContextRecId == journal.RecId
join User from workflowTrackingTable
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Submission;
journal.ReportedAsReadyBy = workflowTrackingTable.User;
}
}
Subscribe to:
Posts (Atom)