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

Announcements

News and Announcements icon
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,573 Moderator on at
    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
    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,573 Moderator on at
    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
SajeedMullaji Profile Picture

SajeedMullaji 698

#2
Martin Dráb Profile Picture

Martin Dráb 327 Most Valuable Professional

#3
CU10121822-0 Profile Picture

CU10121822-0 320

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans