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, ...
Suggested Answer

To edit Field on form by the specific user

(1) ShareShare
ReportReport
Posted on by 1,836
 I have purchse id field in form which i want to make editable only by specific user but the form record is having edit code 
[Form]public class EHIGeneralPurchase extends FormRun{  void editRecord()    {        ;        if(EHIGeneralPurchase.WorkflowState == EHIWorkflowState::Draft            || EHIGeneralPurchase.WorkflowState == EHIWorkflowState::Rejected            || EHIGeneralPurchase.WorkflowState == EHIWorkflowState::ChangeRequested)        {            EHIGeneralPurchase_ds.allowEdit(true);        }        else        {            EHIGeneralPurchase_ds.allowEdit(false);        }     }   public void initValue()        {            super();            element.editRecord();        }        public void init()        {            super();            element.editRecord();        }        public void cursorNotify(int _event)        {            super(_event);            element.editRecord();        }    }
 I want to add my code here to edit my field on certian condition below is my code 
 WorkflowWorkItemTable           workflowWorkItemTable;                SysWorkflowTable                sysWorkflowTableHeader, sysWorkflowTableLine;                WorkflowCorrelationId           correlationId;                if(EHIGeneralPurchase.WorkflowState == EHIWorkflowState::InReview)                {                    select firstonly WorkflowCorrelationId from sysWorkflowTableHeader                        where sysWorkflowTableHeader.ContextTableId == tableNum(EHIGeneralPurchase)                            && sysWorkflowTableHeader.ContextRecId ==  EHIGeneralPurchase.RecId;                    correlationId = sysWorkflowTableHeader.WorkflowCorrelationId;                    if (!SysWorkflowTable::isRootWorkflow(correlationId) && !sysWorkflowTableHeader)                    {                        select firstonly WorkflowCorrelationId from sysWorkflowTableLine                            where sysWorkflowTableLine.ParentCorrelationId == correlationId;                        correlationId = sysWorkflowTableLine.WorkflowCorrelationId;                    }                    select firstonly RecId from workflowWorkItemTable                        where workflowWorkItemTable.CorrelationId == correlationId                            && workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending                            &&  workflowWorkItemTable.UserId == curUserId();                    if(workflowWorkItemTable.RecId)                    {                        EHIGeneralPurchase_DTPurchId1.allowEdit(true);                    }                    else                    {                        EHIGeneralPurchase_DTPurchId1.allowEdit(false);                    }                }                else                {                    EHIGeneralPurchase_DTPurchId1.allowEdit(false);                            }
 
how can i bypass the edit record code and make my field editable on my form  can any one guide me on this.
I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at
    To edit Field on form by the specific user
    Hi, Instead of By passing standard code, in this case ,you can create Dialog with your field (editable). Create Menu Item and add in the form so user can click on menu item and enter value to update. You can assign security privilege to the users who need access.
  • Dineshkarlekar Profile Picture
    1,836 on at
    To edit Field on form by the specific user
    dialog is not he requirement , i need to do it like that , i have made changes the code is working but all the fields are getting enable in review state i want only one field enable in review state 
      void editRecord()
        {
            ;
            if(EHIGeneralPurchase.WorkflowState == EHIWorkflowState::Draft
                || EHIGeneralPurchase.WorkflowState == EHIWorkflowState::Rejected
                || EHIGeneralPurchase.WorkflowState == EHIWorkflowState::ChangeRequested
                || EHIGeneralPurchase.WorkflowState == EHIWorkflowState::InReview)
            {
                EHIGeneralPurchase_ds.allowEdit(true);
            }
            else
            {
                EHIGeneralPurchase_ds.allowEdit(false);
            }
                   
                    WorkflowWorkItemTable           workflowWorkItemTable;
                    SysWorkflowTable                sysWorkflowTableHeader, sysWorkflowTableLine;
                    WorkflowCorrelationId           correlationId;
    
                    if(EHIGeneralPurchase.WorkflowState == EHIWorkflowState::InReview)
                    {
                        select firstonly WorkflowCorrelationId from sysWorkflowTableHeader
                            where sysWorkflowTableHeader.ContextTableId == tableNum(EHIGeneralPurchase)
                                && sysWorkflowTableHeader.ContextRecId ==  EHIGeneralPurchase.RecId;
    
                        correlationId = sysWorkflowTableHeader.WorkflowCorrelationId;
    
                        if (!SysWorkflowTable::isRootWorkflow(correlationId) && !sysWorkflowTableHeader)
                        {
                            select firstonly WorkflowCorrelationId from sysWorkflowTableLine
                                where sysWorkflowTableLine.ParentCorrelationId == correlationId;
                            correlationId = sysWorkflowTableLine.WorkflowCorrelationId;
                        }
    
                        select firstonly RecId from workflowWorkItemTable
                            where workflowWorkItemTable.CorrelationId == correlationId
                                && workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending
                                &&  workflowWorkItemTable.UserId == curUserId();
    
                        if(workflowWorkItemTable.RecId)
                        {
                            EHIGeneralPurchase_DTPurchId1.allowEdit(true);
                           
                        }
                        else
                        {
                            EHIGeneralPurchase_DTPurchId1.allowEdit(false);
                        }
                    }
                    else
                    {
                        EHIGeneralPurchase_DTPurchId1.allowEdit(false);
                      
                    }
    
        }
     
  • Mohit Rampal Profile Picture
    12,565 Moderator on at
    To edit Field on form by the specific user
    We can't enable one field if Datasource is non editable. That's why I suggested to create Dialog. We had similar requirement where datasource record is non editable and create dialog to cater the functionality to update values in some fields.

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…

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
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans