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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Java script code for special access

(0) ShareShare
ReportReport
Posted on by

Hi experts, I need code for user X in this situation:

X can Create and Read Form A in Status reason 0,

but when status Reason change to 1 and the owner is not equal to X, X only can change status reason and All form A is disabled except Status reason.

Can U help me for writing js?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at

    Hi Roya,

    I recommend that you should do with plugin, because javascript works client-side and easy to disable / hack.

    You should register your plugin on pre-validation or pre-operation step and retrieve your record data (with IOrganizationService.Retrieve) and check your logic. If data not matched with your business steps throw an exception inside plugin.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    if using JavaScript , user can easily "hack" through using file import or bulk edit. So, plugin would be more suitable in this case , throw some meaningful message when necessary

  • Community Member Profile Picture
    on at

    the problem is I don't know how i can create plugin and also use it.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Roya,

    You can implement below java-script  code in your form on load event, and inside for each you need to check the status field with your condition . Hope this helps

    function MarkAllFieldReadOnly() {

    Xrm.Page.ui.controls.forEach(function (control, index) {

    try{

    control.setDisabled(true);

    }

    catch (e)

    {

    }

    });

    }

    Mark it as answer if this helps.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    You can take a look  : 

    Plugin Development for Dynamics 365.

    Step by Step Youtube.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans