Thursday, January 8, 2015

Changing Labels values using X++

I have come to a requirement where I need to change the values of labels defined in AX on run-time using X++. So, after some initial workout I found the solution to it.

For this solution you need to use SysLabelEdit class.
Click here SysLabelEdit class. 

static void LabelChangeJob(Args _args)
{
    SysLabelEdit sysLabelEditLocal;
    
    sysLabelEditLocal = new sysLabelEdit();
    info(strFmt('Before Label changes : %1', "@IQL112"));
    
    sysLabelEditLocal.labelModify('en-us',  sysLabelEditLocal.findLabel('en-us', 'Testing Label 1'), "Testing Label", "", SysLabelApplModule::None);
    
    info(strFmt('After Label changes : %1', "@IQL112"));
}

Output


Wednesday, January 7, 2015

Getting comments on workflow using X++

This blog post shows the code for extracting comments provided on workflow at the time of submission.

This method requires RecId of the record on which workflow was executed. I used this code for fetching comments provided at the time of submitting workflow on Purchase order.

public static Notes getComments(RecId     _purchTableRecId)
{
    WorkflowTrackingStatusTable     workflowtrackingstatustable;
    WorkflowTrackingTable           workflowtrackingtable;
    WorkflowTrackingCommentTable    workflowTrackingCommentTable;

    select firstOnly RecId from workflowtrackingstatustable
        join RecId from workflowtrackingtable
            where workflowtrackingstatustable.ContextRecId             == _purchTableRecId //RecId of the record
               && workflowtrackingstatustable.TrackingStatus            != WorkflowTrackingStatus::Cancelled
               && workflowtrackingtable.TrackingContext                 == workflowtrackingcontext::Workflow
               && workflowtrackingtable.TrackingType                    == workflowtrackingtype::Submission
               && workflowtrackingtable.WorkflowTrackingStatusTable     == workflowtrackingstatustable.RecId
        join Comment from workflowTrackingCommentTable
            where workflowTrackingCommentTable.WorkflowTrackingTable    == workflowtrackingtable.RecId;

    return workflowTrackingCommentTable.Comment;
}