web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Custom Workflow getting error 'Field location must be filled'

(0) ShareShare
ReportReport
Posted on by 2,382

Hi AX Experts,

Today I just follow some blogs to create custom workflow in AR. Once I submit form getting warning 'Field location must be filled in' and 'Field type must be filled in'.

I used custTable and custTableListPage for workflow.

Please give me some suggestion.

Thanks.

2251.error1.JPG

Customer-Master.JPG 

I have the same question (0)
  • Mohammad Raziq Ali Profile Picture
    2,486 on at

    Hello faiz,

    can you please share the XPO file for this change if you have it handy?

    Regards,

    Raziq

  • faiz7049 Profile Picture
    2,382 on at

    Thanks to all. Fixed now.

    After updated code.

    public static void UpdateCustWorkflowState(RefRecId _recId,CustApprovalWorkflowState _state)
    {
        CustTable custTable = CustTable::findRecId(_recId,true);
        ttsBegin;
       // custTable.CustApprovalWorkflowState=_state;
        switch(_state)
        {
        case CustApprovalWorkflowState::Approved:
        custTable.Blocked = 0;
        break;
    
        case CustApprovalWorkflowState::ChangeRequest:
        custTable.Blocked = 2;
            break;
    
            case CustApprovalWorkflowState::Completed:
    
                custTable.Blocked = 0;
                break;
    
            case CustApprovalWorkflowState::PendingCancellation:
                custTable.Blocked = 2;
    
                            break;
            case CustApprovalWorkflowState::Returned:
                custTable.Blocked = 2;
    
    
                break;
    
            case CustApprovalWorkflowState::Submitted:
                custTable.Blocked = 2;
                break;
    
        default:
    
            info("Approved");
    
        break;
        }
    
        custTable.update();
        ttsCommit;
    }

  • faiz7049 Profile Picture
    2,382 on at

    Thank to all. It's fixed.

    after correction the code.

    public static void UpdateCustWorkflowState(RefRecId _recId,CustApprovalWorkflowState _state)
    {
        CustTable custTable = CustTable::findRecId(_recId,true);
        ttsBegin;
       // custTable.CustApprovalWorkflowState=_state;
        switch(_state)
        {
        case CustApprovalWorkflowState::Approved:
        custTable.Blocked = 0;
        break;
    
        case CustApprovalWorkflowState::ChangeRequest:
        custTable.Blocked = 2;
            break;
    
            case CustApprovalWorkflowState::Completed:
    
                custTable.Blocked = 0;
                break;
    
            case CustApprovalWorkflowState::PendingCancellation:
                custTable.Blocked = 2;
    
                            break;
            case CustApprovalWorkflowState::Returned:
                custTable.Blocked = 2;
    
    
                break;
    
            case CustApprovalWorkflowState::Submitted:
                custTable.Blocked = 2;
                break;
    
        default:
    
            info("Approved");
    
        break;
        }
    
        custTable.update();
        ttsCommit;
    }
    

  • faiz7049 Profile Picture
    2,382 on at

    Its seems ok...

    1:

       public boolean canSubmitToWorkflow(str _workflowType = '')
    {
        boolean ret;
    
        ret = (this.RecId != 0 && this.CustApprovalWorkflowState == CustApprovalWorkflowState::NotSubmitted);
    
    
        return ret;
    }
    

    2: Yes Base enum update base on approval/Rejection:

    public static void UpdateCustWorkflowState(RefRecId _recId,CustApprovalWorkflowState _state)
    {
        CustTable custTable = CustTable::findRecId(_recId,true);
        ttsBegin;
        custTable.CustApprovalWorkflowState=_state;
        switch(_state)
        {
        case CustApprovalWorkflowState::Approved:
        custTable.Blocked = 0;
        break;
    
        case CustApprovalWorkflowState::ChangeRequest:
        custTable.Blocked = 2;
            break;
    
            case CustApprovalWorkflowState::Completed:
    
                custTable.Blocked = 0;
                break;
    
            case CustApprovalWorkflowState::PendingCancellation:
                custTable.Blocked = 2;
    
                            break;
            case CustApprovalWorkflowState::Returned:
                custTable.Blocked = 2;
    
    
                break;
    
            case CustApprovalWorkflowState::Submitted:
                custTable.Blocked = 2;
                break;
    
        default:
    
            info("Approved");
    
        break;
        }
    
        custTable.update();
        ttsCommit;
    }
    

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Faiz,

    You will need to check two things -

    1. the canSubmitToWorkflow method.

    2. The WorkflowStatus field added to the CustTable. Is the value getting updated properly when the workflow is approved/rejected?

  • faiz7049 Profile Picture
    2,382 on at

    Thanks to all. Problem fixed after workflow code changes . As I told that this code got from blogs but its good for learning.

    Now I face another issue. Once I submitted the form for approval its run fine but when I get notification that request is approved or reject based on approval action same time submit button again back and it force me to again submit if I want to see view history. After submitted same workflow started again (means now two;1 is pending and other is completed).

    I don't know where I should change code.

    CustWFSubitManger code:

    public static void main(Args _args)
    {
    
         CustTable                           CustTable;
        CustWFSubmitManager                 submitManger;
        recId _recId =                      _args.record().RecId;
        WorkflowCorrelationId               _workflowCorrelationId;
    
        WorkflowTypeName                _workflowTypeName = workFlowTypeStr("CustWF");
        WorkflowComment                 note="";
        WorkflowSubmitDialog            workflowSubmitDialog;
    
        submitManger= new CustWFSubmitManager();
    
    
        workflowSubmitDialog = WorkflowSubmitDialog::construct(_args.caller().getActiveworkflowConfiguration());
    
    
        workflowSubmitDialog.run();
    
        if(workflowSubmitDialog.parmIsClosedOK())
    
        {
          custTable = _args.record();
    
            note =   workflowSubmitDialog.parmWorkflowComment();
    
      try
            {
                ttsBegin;
    
    
           _workflowCorrelationId = Workflow::activateFromWorkflowType(_workflowTypeName,CustTable.RecId, note, NoYes::No);
    
    CustTable.CustApprovalWorkflowState = CustApprovalWorkflowState::Submitted;
                CustTable.update();
    
          ttsCommit;
    
                info("Submitted to workflow");
    
            }
    
            catch(Exception::Error)
    
            {
                error("error");
            }
    
    
    }
    
        _args.caller().updateWorkFlowControls();
    
    
    }
    

    CustomerApprovalREsubmitActionManager code:

    public static void main(Args _args)
    {
    
         RecId       recId;
        TableId     tableId;
        CustTable   custTable;
        WorkflowWorkItemTable   workItem;
        WorkflowWorkItemActionDialog workflowWorkItemActionDialog;
    
        recId   =   _args.record().RecId;
        tableId =   _args.record().TableId;
        custTable  =    _args.record();
        workItem    =   _args.caller().getActiveWorkflowWorkItem();
    
    
        if(workItem.RecId > 0)
    
        {
    
     try
            {
    
    
    
      workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct(workItem,WorkflowWorkItemActionType::Resubmit, new MenuFunction(_args.menuItemName(),_args.menuItemType()));
    
      workflowWorkItemActionDialog.run();
    
                if(workflowWorkItemActionDialog.parmIsClosedOK())
    
                {
         if(custTable.CustApprovalWorkflowState ==CustApprovalWorkflowState::ChangeRequest)
    
                    {
    
       workItem = _args.caller().getActiveWorkflowWorkItem();
                        WorkflowWorkItemActionManager::dispatchWorkItemAction(workItem,workflowWorkItemActionDialog.parmWorkflowComment(),workflowWorkItemActionDialog.parmTargetUser(),WorkflowWorkItemActionType::Resubmit,_args.menuItemName(),false);
       custTable.CustApprovalWorkflowState = CustApprovalWorkflowState::ChangeRequest;
    
           ttsBegin;
                        custTable.dataSource().write();
    
           ttsCommit;
    
    }
       else
       {
          throw Exception::Error;
       }
    
                }
            }
            catch(Exception::Error)
    
            {
                throw error(strFmt("Error"));
    
            }
        }
    
    
        _args.caller().updateWorkflowControls();
    
    
    }

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Faiz,

    Since this is a custom workflow, please share your design and code for the same. Have you tried to debug the submit event to check where the error is being thrown from?

  • faiz7049 Profile Picture
    2,382 on at

    Hi Experts,

    Kindly help me out.

  • faiz7049 Profile Picture
    2,382 on at

    Hi ,

    I am able to create record in custTable table without any issue. but getting error after workflow submission. 

  • Suggested answer
    mhdshb1 Profile Picture
    1,250 on at

    Hi,

    So you compare the custTable with all the layers and you did not find the customization?

    Can you try to create an new record from the table custTable, you should get the same warnings.

    It will give you some idea where is the customizations are done.

    Regards,

    M

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 417 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 325 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans