Solved

Change the Status and save entity from the Form

Posted on 2012-03-15
3
456 Views
Last Modified: 2012-04-11
I need to change the status of an entity and save it on click of a custom ribbon button.
If I change the status using the StatusRequest and response I first need to have the record saved. As soon as I do a Xrm.Pages.Data.entity.save the form reloads and I cannot call the state request response functions.

How does the standard CRM do it in on the mark complete ?

Any way this can be accomplised ?
0
Comment
Question by:Mayank_Bhardwaj
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
Comment Utility
Hi Mayank_Bhardwaj,

CRM has different masages to accomplish such tasks.
Try lookin into SetState message. Basically you will write JavaScript to fire a SetState method and then use Save. Remember if you are disabling the record then Save will not work after SetState.

Otherthat that you could do it this way
Keep a hidden field on the form say StateChange. While OnSave Set It To : true. OnLoad : Check if it is true or not, if yes then fire the SetState command or do whatever else you need to do. Also dont forget to change StateChange to false or relevant value after you have fired SetState request.

Regards,
Chinmay.
0
 

Author Comment

by:Mayank_Bhardwaj
Comment Utility
Hi Chimay,
This is Mayank, your trainees Yamaha :-). Well the problem with SetState message is that the record should already be saved, cos it needs a guid of the entity as a parameter.
What I am trying to accomplish here is as follows
I have this SMS Entity. I have created a Ribbon Button called Send. On a new SMS form the user fills up all the details and when the user clicks on the send button, the sms entity should be saved with the state = Scheduled and Status Reason as Scheduled too.
0
 
LVL 27

Expert Comment

by:Chinmay Patel
Comment Utility
Hi Mayank,

Of course I don't forget easy. :)

Now consider the second workaround I have mentioned. If you are not comfortable with that approach, you can always go with a Plugin.

Let me know if you see any challenges here.

Regards,
Chinmay.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now