display WorkflowUser user()
{
WorkflowWorkItemTable workflowWorkItemTable;
WorkflowTrackingTable workflowTrackingTable;
EmplId emplId;
;
select firstonly workflowWorkItemTable where
workflowWorkItemTable.RefTableId == this.TableId &&
workflowWorkItemTable.RefRecId == this.RecId &&
workflowWorkItemTable.CompanyId == this.DataAreaId &&
workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending;
workflowTrackingTable = Workflow::findLastTrackingRecordForWorkItem (workflowWorkItemTable);
emplId = SysCompanyUserInfo::find(workflowTrackingTable.User).UserId;
return emplId;
}
display Emplid LastApprovedby()
{
EmplId emplId;
WorkflowTrackingTable workflowtrackingtable;
;
select firstonly reverse workflowtrackingtable order by recid asc
where workflowtrackingtable.ContextRecId == this.RecId
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval;
if (workflowtrackingtable)
{
emplId = SysCompanyUserInfo::find(workflowTrackingTable.User).UserId;
}
return emplId;
}
static void Workflow_Approver(Args _args)
{
LedgerJournalTable tab;
WorkflowTrackingTable WorkFlowtab, WorkFlowtab1;
UserInfo userinfo;
;
select tab where tab.JournalNum == '';
While select tab
join WorkFlowtab
where WorkFlowtab.ContextRecId == 5637302079
&& WorkFlowtab.TrackingContext == WorkflowTrackingContext::WorkItem
{
Select firstonly WorkFlowtab1
where WorkFlowtab1.TrackingType == WorkflowTrackingType::Approval
&& WorkFlowtab1.ContextRecId == WorkFlowtab.ContextRecId;
if (!WorkFlowtab1)
{
Select UserInfo
where UserInfo.id == WorkFlowtab.User;
if (UserInfo)
info(strfmt("%1|%2",tab.JournalNum, UserInfo.name));
}
}
}
static void Workflow_Approver_pendingFromaUser(Args _args)
{
LedgerJournalTable tab;
WorkflowTrackingTable WorkFlowtab, WorkFlowtab1;
UserInfo userinfo;
;
While select WorkFlowtab order by WorkFlowtab.Recid desc
where WorkFlowtab.ContextTableId == tablenum(LedgerjournalTable)
&& WorkFlowtab.TrackingContext == WorkflowTrackingContext::WorkItem
&& WorkFlowtab.TrackingType == WorkflowTrackingType::Approval
&& WorkFlowtab.User == 'Raj'
{
select tab where tab.RecId ==
info();
}
}
Fetch the userid who approved the workflow:
In AX 2012:
Below code fetches the user id’s who approved the PO workflow.
select firstonly workflowtrackingstatustable
join workflowtrackingtable
where workflowtrackingstatustable .ContextRecId == purchtable.recid
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval
&& workflowtrackingtable.WorkflowTrackingStatusTable == workflowtrackingstatustable .recid;
{
approvername = workflowtrackingtable.User;
}
this code might help you to get a PO approver(in the same way you can get the approver name of any order/ journal
by passing the approved record id as context rec id).
Note:
In case there are multiple approvers use While to select multiple approver user id’s from workflowtrackingstatustable.
In AX 2009:
Below code fetches the user id’s who approved the PO workflow.
select firstonly workflowtrackingtable order by recid asc
where workflowtrackingtable.ContextRecId == purchtable.recid
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval;
if (workflowtrackingtable)
{
approvername = workflowtrackingtable.User;
}
this code might help you to get a PO approver(in the same way you can get the approver name of any order/ journal
by passing the approved record id as context rec id).
Note:
In case there are multiple approvers use While to select multiple approver user id’s from workflowtrackingtable.
{
WorkflowWorkItemTable workflowWorkItemTable;
WorkflowTrackingTable workflowTrackingTable;
EmplId emplId;
;
select firstonly workflowWorkItemTable where
workflowWorkItemTable.RefTableId == this.TableId &&
workflowWorkItemTable.RefRecId == this.RecId &&
workflowWorkItemTable.CompanyId == this.DataAreaId &&
workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending;
workflowTrackingTable = Workflow::findLastTrackingRecordForWorkItem (workflowWorkItemTable);
emplId = SysCompanyUserInfo::find(workflowTrackingTable.User).UserId;
return emplId;
}
display Emplid LastApprovedby()
{
EmplId emplId;
WorkflowTrackingTable workflowtrackingtable;
;
select firstonly reverse workflowtrackingtable order by recid asc
where workflowtrackingtable.ContextRecId == this.RecId
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval;
if (workflowtrackingtable)
{
emplId = SysCompanyUserInfo::find(workflowTrackingTable.User).UserId;
}
return emplId;
}
static void Workflow_Approver(Args _args)
{
LedgerJournalTable tab;
WorkflowTrackingTable WorkFlowtab, WorkFlowtab1;
UserInfo userinfo;
;
select tab where tab.JournalNum == '';
While select tab
join WorkFlowtab
where WorkFlowtab.ContextRecId == 5637302079
&& WorkFlowtab.TrackingContext == WorkflowTrackingContext::WorkItem
{
Select firstonly WorkFlowtab1
where WorkFlowtab1.TrackingType == WorkflowTrackingType::Approval
&& WorkFlowtab1.ContextRecId == WorkFlowtab.ContextRecId;
if (!WorkFlowtab1)
{
Select UserInfo
where UserInfo.id == WorkFlowtab.User;
if (UserInfo)
info(strfmt("%1|%2",tab.JournalNum, UserInfo.name));
}
}
}
static void Workflow_Approver_pendingFromaUser(Args _args)
{
LedgerJournalTable tab;
WorkflowTrackingTable WorkFlowtab, WorkFlowtab1;
UserInfo userinfo;
;
While select WorkFlowtab order by WorkFlowtab.Recid desc
where WorkFlowtab.ContextTableId == tablenum(LedgerjournalTable)
&& WorkFlowtab.TrackingContext == WorkflowTrackingContext::WorkItem
&& WorkFlowtab.TrackingType == WorkflowTrackingType::Approval
&& WorkFlowtab.User == 'Raj'
{
select tab where tab.RecId ==
info();
}
}
Fetch the userid who approved the workflow:
In AX 2012:
Below code fetches the user id’s who approved the PO workflow.
select firstonly workflowtrackingstatustable
join workflowtrackingtable
where workflowtrackingstatustable .ContextRecId == purchtable.recid
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval
&& workflowtrackingtable.WorkflowTrackingStatusTable == workflowtrackingstatustable .recid;
{
approvername = workflowtrackingtable.User;
}
this code might help you to get a PO approver(in the same way you can get the approver name of any order/ journal
by passing the approved record id as context rec id).
Note:
In case there are multiple approvers use While to select multiple approver user id’s from workflowtrackingstatustable.
In AX 2009:
Below code fetches the user id’s who approved the PO workflow.
select firstonly workflowtrackingtable order by recid asc
where workflowtrackingtable.ContextRecId == purchtable.recid
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval;
if (workflowtrackingtable)
{
approvername = workflowtrackingtable.User;
}
this code might help you to get a PO approver(in the same way you can get the approver name of any order/ journal
by passing the approved record id as context rec id).
Note:
In case there are multiple approvers use While to select multiple approver user id’s from workflowtrackingtable.
specsiYturpo Lisa Sanchez https://wakelet.com/wake/gudRvnlE-FQwOCGeubgya
ReplyDeletepoicatetatb