Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Sales lines security
Finance forum
Unanswered

Sales lines security

Posted on by 216
Hi,

I have added a NoYes field called 'Field1' to SalesLine. Whenever i select some lines and click a button, this 'Field1' field is updated to yes for those selected lines.
Now if 'Field1' field value is yes, the line should not be editable by anyone. Only sys admin can edit the line. How to do that?

is this a good solution?

maybe on active method of salesLine:

if(Global::isSystemAdministrator() && this.Field1== NoYes::Yes)
{
   this.allowEdit(False);
}
  • CU04051814-0 Profile Picture
    CU04051814-0 216 on at
    Sales lines security
    Hi Andre,
     
    As a start i put code on both active formdatasource method and modified formDatasourceField method.
     
    Is it normal that if i was standing on a NOT locked record, that i see the check box for the Locked record above it as enabled, however when i try to untick this above record, it will convert the record to read mode and not take my tick. Is this normal behavior? If not what shall i do?
     
    And what table methods you would like me to add that validation?
     
    And what entity methods shall i add the code to?
     
    The business use for this one, is that we lock the field once we send it to another system, so once it's sent we don't anyone to play with that record except for the sys admin
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 287,696 Super User on at
    Sales lines security
    Hi,
     
    When adding the code as you suggested, this will work on the form only. In case data is to be updated using integrations, you can add validations on the table and/or data entity. That will add an additional level of security. 

    Personally, I would not rely on the system administrator to be able to update the field, but have a business person having a non system admin role being able to make updates. What is the business reason for blocking the line and have a system administrator involved in case an update is required? 
     
    A security policy will be a bit harder here. It will then already check in case the Locked field will be enabled. It will not check anymore in case a user will disable the Locked field.
     
     
     
     
  • Anton Venter Profile Picture
    Anton Venter 9,343 Super User on at
    Sales lines security
    Hello,
     
    Your solution seems fine to me, I don't how you will be able to do the same with security though. When are the lines locked?
  • CU04051814-0 Profile Picture
    CU04051814-0 216 on at
    Code to prevent sales lines editing
    Hi,

    I think I might be able handle the code by testing, my question was, is the solution good or shall i do it with security policy for example..etc?
  • Waed Ayyad Profile Picture
    Waed Ayyad 3,706 on at
    Secuirty
    Hi,
     
    Does locked filed be editable from the form? if yes then you should add the same code to the modified field of the Locked field, you can create new method on the DataSource and call it in all places you want.
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans