Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Field changed only in Client side and not in server side(Database) CRM 2016

Posted on by 100

Hi All,

I have difficulty in changing the field value in server side (i.e) database side. The field changed only in client side (i.e in the form - front end).

This is how it is working now: 

On the Task entity, when user clicked on the "Mark Complete" button, the Activity Status changed to "Completed" and "Actual End Date" gets populated to the date when user clicked on mark complete button. Once this action is done, form becomes read-only.

My requirement is, once the activity status is completed, change the custom field "processing status" to "Completed". I wrote a java script and changed the status. It changed only on the client side, but not updated on the database. 

Here is my Java scrip I wrote to chnage the processing status to "Completed".

function processingStatus()
{
var actualenddate = Xrm.Page.getAttribute("actualend").getValue();

if (actualenddate != null)
{
Xrm.Page.getAttribute("cf_processingstatus").setValue(979570001);
Xrm.Page.getAttribute(“cf_processingstatus”).setSubmitMode("always");
Xrm.Page.getControl("cf_processingstatus").setVisible(true);
}
}

Here is the screen shot of the form. 

Before User click "Mark Complete":

pastedimage1588463889686v1.png

After User clicked "Mark Complete"Button:

pastedimage1588463948229v3.png

I'm happy that the processing status changed to "Completed", but when I did an advanced find to see, I didn't get any results and then I realized it just updated only on the client side and not on the server side. I found this, as in the other form, it is still in pending status.

pastedimage1588463954066v4.png

Anyone help is much appreciated here. 

Many Thanks in advance,

  • Poornimaa Profile Picture
    Poornimaa 100 on at
    RE: Field changed only in Client side and not in server side(Database) CRM 2016

    Hi Marco,

    Thanks for responsing my query. I tried using Web API as you sugested. Here is my coding for the same.

    I'm using CRM 2016 version 8.1. Is webApi available for this version? If not could you please suggest me an alternative.

    function processingStatus()

    {

       var actualenddate = Xrm.Page.getAttribute("actualend").getValue();

       var id = Xrm.Page.data.entity.getId();    

       if (actualenddate != null)

       {

           var data = { "cf_processingstatus" : "Completed"}

           // update the record

           Xrm.WebApi.updateRecord("Task", id, data).then(

               function success(result) {

                   console.log("Processing Status updated");

                   // perform operations on record update

               },

               function (error) {

                   console.log(error.message);

                   // handle error conditions

               }

           );

      }

    }

    and I'm getting the below error.

    TypeError: Cannot read property 'updateRecord' of undefined  

    at processingStatus.

    Could you please help me here?

    Many Thanks,

  • Suggested answer
    Marco.P Profile Picture
    Marco.P 2,405 on at
    RE: Field changed only in Client side and not in server side(Database) CRM 2016

    Hi,

    I think the problem here is that you only set the value on form, but you do not save the new value.

    You can try to directly updating the field using web API:

    docs.microsoft.com/.../updaterecord

    Or you try with a workflow, something like this:

    pastedimage1588415663040v1.png

    Hope it helps,

    Marco


    If you've found the answer helpful, please mark it as Verified.

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