Interview Questions

Monday, May 12, 2014

Workflow PurchReq most Recent Comment in ax 2009

//PurchReqmostRecentComment EDT is used for recent comment.
display PurchReqmostRecentComment mostRecentComment()
{
    WorkflowTrackingCommentTable        workflowTrackingCommentTable;
    WorkflowWorkItemTable               workflowWorkItemTable;
    WorkflowTrackingTable               workflowTrackingTable;
    DirPartyTable                       dirPartyTable;
    EmplTable                           emplTable;
    PurchReqMostRecentComment           comment;
    EmplId                              emplId;
    UserInfo                            userInfo;
    Name                                name;
    ;
    select firstonly workflowWorkItemTable
        order by CreatedDateTime desc where
        workflowWorkItemTable.RefTableId == this.TableId &&
        workflowWorkItemTable.RefRecId == this.RecId &&
        workflowWorkItemTable.CompanyId == this.DataAreaId &&
        workflowWorkItemTable.Status == WorkflowWorkItemStatus::Completed;

        workflowTrackingTable = Workflow::findLastTrackingRecordForWorkItem (workflowWorkItemTable);
        workflowTrackingCommentTable = WorkflowTrackingCommentTable::find (workflowTrackingTable.TrackingId);
        emplId = SysCompanyUserInfo::find(workflowTrackingTable.User).EmplId;
        if (emplId)
        {
            select firstonly Name from dirPartyTable
            exists join emplTable
            where dirPartyTable.PartyId == emplTable.PartyId &&
            emplTable.EmplId == emplId;
            name = dirPartyTable.Name + ' (' + emplId + ') : ';
        }
        else
        {
            select firstonly userInfo where userInfo.Id == workflowTrackingTable.User;
            name = userInfo.Name + ' (' + workflowTrackingTable.User + ') : ';
        }
        comment = strfmt("%1",DateTimeUtil::applyTimeZoneOffset (workflowTrackingCommentTable.CreatedDateTime, DateTimeUtil::getUserPreferredTimeZone())) + ' ';
        comment += name;
        comment += workflowTrackingCommentTable.Comment;
    return comment;
}


// PurchReqRequiredActionDueDateStr EDT is used for requiredactionduedate
display PurchReqRequiredActionDueDateStr requiredActionDueDate()
{
    WorkflowWorkItemTable               workflowWorkItemTable;
    PurchReqRequiredActionDueDateStr    dueDateStr;
    ;
    select firstonly DueDateTime from workflowWorkItemTable
        where workflowWorkItemTable.RefTableId == this.TableId &&
        workflowWorkItemTable.RefRecId == this.RecId &&
        workflowWorkItemTable.CompanyId == this.DataAreaId &&
        workflowWorkItemTable.UserId == curuserid() &&
        workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending;
        if (workflowWorkItemTable.DueDateTime != DateTimeUtil::minValue())
        {
            dueDateStr = strfmt("%1",DateTimeUtil::applyTimeZoneOffset (workflowWorkItemTable.DueDateTime, DateTimeUtil::getUserPreferredTimeZone()));
        }
    return dueDateStr;
}


// purchreqRequiredAction EDT is used for required action.
display purchreqRequiredAction requiredAction()
{
    WorkflowWorkItemTable       workflowWorkItemTable;
    PurchReqRequiredAction      text;
    ;
    select firstonly workflowWorkItemTable
        where workflowWorkItemTable.RefTableId == this.TableId &&
        workflowWorkItemTable.RefRecId == this.RecId &&
        workflowWorkItemTable.CompanyId == this.DataAreaId &&
        workflowWorkItemTable.UserId == curuserid() &&
        workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending;
        if (workflowWorkItemTable.RecId)
        {
            switch (this.WorkflowState)
            {
                case WorkflowState::ChangeRequest :
                text = "@SYS109048";
                break;
                case WorkflowState::PendingApproval :
                text = "@SYS109902";
                break;
                case WorkflowState::PendingComplete :
                text = "@SYS112063";
                break;
            }
        }
    return text;
}

No comments:

Post a Comment