Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Custom Workflow getting error 'Field location must be filled'

Posted on by 1,879

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 

  • Mohammad Raziq Ali Profile Picture
    Mohammad Raziq Ali 2,432 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    Hello faiz,

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

    Regards,

    Raziq

  • faiz7049 Profile Picture
    faiz7049 1,879 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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
    faiz7049 1,879 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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
    faiz7049 1,879 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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
    Gunjan Bhattachayya 35,421 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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
    faiz7049 1,879 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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
    Gunjan Bhattachayya 35,421 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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
    faiz7049 1,879 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    Hi Experts,

    Kindly help me out.

  • faiz7049 Profile Picture
    faiz7049 1,879 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    Hi ,

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

  • Suggested answer
    mhdshb1 Profile Picture
    mhdshb1 1,250 on at
    RE: Custom Workflow getting error 'Field location must be filled'

    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

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans