Answered by:
Super basic help, understanding how CRM works.

Question
-
Hello everyone. I was assigned to do this project through work. I don't know any Javascript, but i do know c#. I am doing very basic level things, like making certain fields required based on the value of a pick list. The problem is i have all the information that i need, but i can't get a hold on the syntax of some of the things.
For example, I can't find the form name, the "compiler" always complains.
This is all the code that i have within my web resource for the time being.
RequiredFields = Function() { FormName.SetFieldReqLevel("new_numberofparticipants", 2); }
FormName isn't actually in the code, but I'm not sure what that should be. the form is named Opportunity, and inside the form Properties, it's called Information. I get a complaint either way.
I understand this is probably very basic but any help is well appreciated. I would like a response that gives me how to get the specific form name and double checks the syntax.
After this part is answered I will be adding more of the code to verify that i am on the right track.
Thanks in advance!
p.s. I am doing this strictly through the provided text editor, I am not doing it through VS.
- Edited by aireland Tuesday, July 31, 2012 6:53 PM Additional Details
Tuesday, July 31, 2012 6:46 PM
Answers
-
Hello,
In case you work with CRM 2011 following script should work fine:
Xrm.Page.getAttribute("new_numberofparticipants").setRequiredLevel("required");
In case you still with 4.0 try to use following code:
crmForm.SetFieldReqLevel("new_numberofparticipants", 1);
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed as answer by JLattimerMVP, Moderator Tuesday, July 31, 2012 7:49 PM
- Marked as answer by aireland Thursday, December 20, 2012 4:27 PM
Tuesday, July 31, 2012 7:39 PMModerator
All replies
-
Hello,
In case you work with CRM 2011 following script should work fine:
Xrm.Page.getAttribute("new_numberofparticipants").setRequiredLevel("required");
In case you still with 4.0 try to use following code:
crmForm.SetFieldReqLevel("new_numberofparticipants", 1);
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed as answer by JLattimerMVP, Moderator Tuesday, July 31, 2012 7:49 PM
- Marked as answer by aireland Thursday, December 20, 2012 4:27 PM
Tuesday, July 31, 2012 7:39 PMModerator -
I get 'Xrm' is undefined. same with the 4.0, which i don't believe is the case, with 'crmForm' is not available.Tuesday, July 31, 2012 7:54 PM
-
I have following questions:
1. What version of CRM do you use 4.0 or 2011?
2. Please provide your full code and how do you register your handlers.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Edited by Andrii ButenkoMVP, Moderator Tuesday, July 31, 2012 7:58 PM
Tuesday, July 31, 2012 7:58 PMModerator -
using CRM 2011You have basically all my code, it was just encapsulated in
RequiredFields = Function() { //code }
I was just trying to get anything going with this. Trying to discover the syntax.
As for the registration of the handlers, i am writing these through Settings>Customization>WebResources.
So i believe that there are no events associated, and I'm not sure how. There are several places to add libraries and such to the controls on the forms.
Tuesday, July 31, 2012 8:28 PM -
You should use function instead of Function.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
Tuesday, July 31, 2012 8:31 PMModerator