Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change the Status and save entity from the Form

Posted on 2012-03-15
3
Medium Priority
?
503 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 1500 total points
ID: 37728606
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
ID: 37728734
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
ID: 37728774
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

972 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