Answered by:
stop close window

Question
-
Hi
I want to capture close event and dont allow user to close the form untill required attribute values are provided.
Please help!!
Thanks in Advance!!
Garfield!!Thursday, October 7, 2010 11:57 AM
Answers
-
You can customise the attribute and set it to 'Business Required' via settings\customisation
If you only want it to be required based on logic, you can do it via javascript in the form's on-save, with something like: -
if(crmForm.all.attributeToSet.DataValue==null) { crmForm.all.attributeToSet.SetFocus(); event.returnValue = false; }
Neil - My CRM Blog- Edited by Neil McD Thursday, October 7, 2010 12:12 PM
- Proposed as answer by Jeff Loucks Thursday, October 7, 2010 12:33 PM
- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:15 PM
Thursday, October 7, 2010 12:09 PM -
It will stop both the "Save" and "Save and Close"
Neil - My CRM Blog- Proposed as answer by Curt Spanburgh MVP ModeratorMVP, Moderator Thursday, October 7, 2010 4:12 PM
- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:15 PM
Thursday, October 7, 2010 1:42 PM -
You're not going to be able to stop closing via the X button. If your users were to exit through that, they would be prompted by IE to confirm that they want to lose their changes.
Neil - My CRM Blog- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:15 PM
Friday, October 8, 2010 8:00 AM
All replies
-
You can customise the attribute and set it to 'Business Required' via settings\customisation
If you only want it to be required based on logic, you can do it via javascript in the form's on-save, with something like: -
if(crmForm.all.attributeToSet.DataValue==null) { crmForm.all.attributeToSet.SetFocus(); event.returnValue = false; }
Neil - My CRM Blog- Edited by Neil McD Thursday, October 7, 2010 12:12 PM
- Proposed as answer by Jeff Loucks Thursday, October 7, 2010 12:33 PM
- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:15 PM
Thursday, October 7, 2010 12:09 PM -
You could make your required attribute as "Business Required
Cheers, Edwin- Proposed as answer by Jeff Loucks Thursday, October 7, 2010 12:32 PM
Thursday, October 7, 2010 12:10 PM -
Thanks for reply!!
i was just taking example of required fields. but actually i have some complex scenario. In this scenario i am fetching fields from other entity and if value of that field is not fetched then i have to change some attribute and dont allow user to close window/form untill he make those changes..
Hope i m clear..
Garfield!!Thursday, October 7, 2010 12:41 PM -
The script above should help you with that. You'll need to replace the logic to cater for the conditions you need to meet, then just use event.returnValue = false; to block the Save.
Neil - My CRM BlogThursday, October 7, 2010 1:31 PM -
i want to stop form from closing not saving....
Garfield!!Thursday, October 7, 2010 1:36 PM -
It will stop both the "Save" and "Save and Close"
Neil - My CRM Blog- Proposed as answer by Curt Spanburgh MVP ModeratorMVP, Moderator Thursday, October 7, 2010 4:12 PM
- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:15 PM
Thursday, October 7, 2010 1:42 PM -
But i m closing through X button of form and not save & Close. Please help!!!
Garfield!!Friday, October 8, 2010 5:35 AM -
i do't understand why you are going block if the user is closing the form(not saving) with out proving the required fields?
if you want to do it on save or save & close then follow the followings
1st of all if the attributes are business required while creating, then while closing the window the system will take care and it will give alert.
on the othe rhand, if you want to make it business required dynamically means with some conditions then use the followins code and after wards if the user is not providing and trying to save it will ask for the same to fill up.
//Set field to not required
crmForm.SetFieldReqLevel("attributeName", 0);
// Set field to business required
crmForm.SetFieldReqLevel("attributeName", 1);for more on this you can click here http://bproud2banindian.blogspot.com
yes.sudhanshu
http://bproud2banindian.blogspot.com
http://ms-crm-2011-beta.blogspot.com- Proposed as answer by yes.sudhanshu Friday, October 8, 2010 6:36 AM
Friday, October 8, 2010 6:35 AM -
You're not going to be able to stop closing via the X button. If your users were to exit through that, they would be prompted by IE to confirm that they want to lose their changes.
Neil - My CRM Blog- Marked as answer by Donna EdwardsMVP Thursday, October 14, 2010 1:15 PM
Friday, October 8, 2010 8:00 AM