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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

(0) ShareShare
ReportReport
Posted on by 384

Dears, 

please advise how to lock directly a form data source after submitting the workflow without refreshing the form knowing it's a custom Form and Workflow.

I have the same question (0)
  • Suggested answer
    abdultp Profile Picture
    867 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    Hi Sylvester,

    I'll provide you the sample code which you modify as per your need. On the form level, write a method called editvalues() where we pass the logic for disabling the edit on datasource based on the workflow state.

    void editvalues()
    {
    ;
    if(Book.WorkflowState == WorkflowState::Draft
    || Book.WorkflowState == WorkflowState::Rejected
    || Book.WorkflowState == WorkflowState::ChangeRequested)
    {
    Book_DS.allowEdit(true);
    }
    else
    {
    Book_DS.allowEdit(false);
    }
    }

    In the form datasource level call this method in the init & cursornotify methods.

    public void init()
    {
    super();
    element.editvalues();
    }

    public void cursorNotify(int _event)
    {
    super(_event);
    element.editvalues();

    }

    If it was helpful, please mark it as verified.

  • sylvesterPowerBi Profile Picture
    384 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    Hello Abdul Wasi,

    the code didn't work, i still have to refresh the form in order to lock the DS :(

    i used it the same exact way you told me

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    Hi sylvesterD365,

    You should call the editValues method from the primary data source active method. Please check the PurchTable data source active method in PurchTable form as an example.

    pastedimage1652862345208v1.png

  • Suggested answer
    abdultp Profile Picture
    867 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    Hi Sylvester,

    Call the editvalues() method in the data source active method too.

    public int active()

           {

               int ret;

               ret = super();        

               element.editvalues();        

               return ret;

           }

  • sylvesterPowerBi Profile Picture
    384 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    both suggestions didn't work :(

  • Gunjan Bhattachayya Profile Picture
    35,423 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    Could you share a screenshot of your form data sources and your code for this?

  • Verified answer
    abdultp Profile Picture
    867 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    make sure you have added the below code after the if(dialog.parmIsClosedOK()) in the main() method of the submitmanager class

    if(FormDataUtil::isFormDataSource(_args.record()))

           {

               FormDataUtil::getFormDataSource(_args.record()).research(true);

           }

           _args.caller().updateWorkflowControls();

  • sylvesterPowerBi Profile Picture
    384 on at
    RE: How to disable form data source after submitting the workflow on custom form without hitting the refresh button ?

    Thanks Abdul Wasi it worked

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

Responsible AI policies

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

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 678

#3
Martin Dráb Profile Picture

Martin Dráb 526 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans