Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Can't able to set value in read only field using plugin

Posted on by

hi Guys,

I have a custom entity called receptionmanagementsystem while save the record want to set value in read only field..but the value is not coming...here it is my code..

if(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName == "new_receptionmanagementsystem")
{

Entity reception = new Entity("new_receptionmanagementsystem");
//string note = "New one is coming to meet you";
reception["new_welcomenote"] = "New one is coming to meet you";
service.Update(reception);

}

*This post is locked for comments

  • DineshRaja Profile Picture
    DineshRaja on at
    RE: Can't able to set value in read only field using plugin

    Thanks Man..after that while trigger the plugin error is coming.. The Error is : Record Is Unavailable

    The requested record was not found or you do not have sufficient permissions to view it.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Can't able to set value in read only field using plugin

    Hi,

    How do you set the value of the field ? If you are setting using JS then try to set setSubmitMode= "always" for   attributes which are read-only in the onsave method using javascript.

    Xrm.Page.getAttribute("FieldName").setSubmitMode("always");

  • Verified answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Can't able to set value in read only field using plugin

    Hi Dinesh,

    Though you are updating a reception entity the plugin doesn't knmow what to update.

    in short you dont have initialize the entity again.

    if(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

    {

    Entity entity = (Entity)context.InputParameters["Target"];  // this is the entity on which your plugin is running so use it.

    if (entity.LogicalName == "new_receptionmanagementsystem")

    {

    // Entity reception = new Entity("new_receptionmanagementsystem"); // no need of this line you have the "entity" object already

    entity ["new_welcomenote"] = "New one is coming to meet you";  

    service.Update(entity);

    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans