You are on page 1of 21

Proteans Software Solutions

JSCRIPTS IN
CRM
Contents

1. Basics Definition

2. Difference between Jscript and Javascript

3. Jscripts in crm

4. Importance and use in crm

5. Advantages

6. Conclusion

www.proteans.com
Definition

JScript .NET is a computer programming language developed by Microsoft based on early or


previous standards of the JavaScript, then JScript language. The primary and strongest
difference, what sets JScript .NET apart is that it is not a simple or regular scripting language

The acronym .NET suggests that JScript .NET uses the .NET Framework to take full advantage of the
operating system on which it is run.

With JScript .NET, you can create console applications, graphical (GUI) Windows application, web-based
applications (ASP.NET), and many more. This is because well written code in a JScript .NET has direct access
to the .NET Framework.

www.proteans.com
Difference between Jscript and Javascript

There is not a very huge difference between jscript and javascript . The basic difference is in their
name .

JavaScript is a scripting language developed by Netscape Communications designed for developing client
and server Internet applications. Netscape Navigator is designed to interpret JavaScript embedded into
Web pages. JavaScript is independent of Sun MicroSystem's Java language.

While Jscript is a scripting language that is developed my Microsoft .Actually Microsoft developed this
language basically to give competition to java script language .

But being almost similar there is still some difference between the two languages .Basically The biggest
difference now between JavaScript and JScript are all of the additional commands that JScript supports
that allow access to ActiveX and the local computer. These commands are intended for use on intranet
sites where you know the configuration of all of the computers and that they are all running Internet
Explorer.

www.proteans.com
Jscripts in CRM
Microsoft Dynamics CRM supports Jscript language and it is widely use for various purposes .
The most common use is for performing validations in form data in client side. Also it is used for accessing
data from another entity and populating the required data in another form .This is mainly done through the
help of the soap request and soap response .

Before moving into the coding part first look at the places where it is generally used .
It is used basically on the events that are present on the form . These events are

1. onLoad Event
2. onSave Event
3. onChange Event

The onLoad event fires whenever the crm form gets loadedie when the page gets invoked . The onSave event
fires whenever we save the crm form . And the onChange event is specific for the particular field i.e for a
particular attribute .. So it gets fired whenever the value in the field gets changed .

www.proteans.com
Basics examples

Some of the basics examples using Jscripts are

1. Getting the objecttypecode of a paritcular entity

 Add a Script to run when a form is loaded


 In the Navigation Pane for the Web application, click Settings, click Customization, and then click Customize
Entities.
 Open the Bank Account entity, and then click Forms and Views.
 Click Form, and then on the Actions toolbar, click More Actions, and then click Edit.
 Click Form Properties.
 Click onLoad, and then click Edit.
 On the Details tab, select the Event is enabled check box to enable the event, and in the text box, enter the
body of the script shown here.

alert("This is the type code: " + crmForm.ObjectTypeCode);

www.proteans.com
Testing the script

 On the Preview menu, click Create Form.


 Your script is executed when the form loads.
 To close the Preview form, on the File menu, click Close.
 Click OK to close the Form Properties dialog box.
 Click Close to close the form, discarding your changes because you do not want to see this alert all the
time.
 Click Close to close the entity.

2.How to access the field and set the value in crm


crmForm.all.attributename.DataValue= Value;
Here
attributename – It is the name of the attribute for which you want to set the data .It can be builtin
attribute or a custom attribute. Eg : new_age

Value – It refers to the string or integer type value that we want to set for a particular attribute .

www.proteans.com
Working with Lookups

We can read values from and set values to most of the Microsoft Dynamics CRM form controls including lookups.
The below example shows how to read values from a primarycontactid lookup control on an account form.
var lookupItem = new Array;
lookupItem = crmForm.all.primarycontactid.DataValue;
if (lookupItem[0] != null)
{
alert(lookupItem[0].name);
alert(lookupItem[0].typename);
alert(lookupItem[0].id);
// A value of 1 = account, and a value of 2 = contact.
alert(lookupItem[0].type);
}
We can also set default value to the lookup field . The below example shows how to set the default values .
var lookupData = new Array();
var lookupItem= new Object();
lookupItem.id = '{1AAC1363-01A1-DB11-8432-0003FF9CE217}';
lookupItem.typename = 'account';
lookupItem.name = 'A Bike Store';
lookupData[0] = lookupItem;
crmForm.all.parentaccountid.DataValue = lookupData;

www.proteans.com
Crm FormTypes

The crmForm has a property called FormType, which allows you to distinguish between the different types of forms you may encounter as a user
creates or edits a CRM Entity.

When a user clicks the New button to create a new Entity, the FormType is set to 1, for Create Form.  If the user clicks the Save button ( not Save
and Close ), CRM will save the record, as expected.  From that point forward, CRM considers the user's operation to be an Edit of existing data,
rather than the entry of New data.
Subsequently, the FormType is changed to reflect that fact: After the Save button is clicked, the FormType is changed to 2, for Update Form.

Working with PickList


1. Changing the default value of the picklist
crmForm.all.new_picklistname.DataValue=1;
Here new_picklistname denotes the name of the picklist attribute. And 1 is the value we have provided .

2.Disabling the Picklist value


crmForm.all.new_picklistname.Disabled=true;

3.Making the attribute invisible or hidden


crmForm.all.new_picklistname.DataValue.style.display=‘none’;
4.Making the attribute value visible
crmForm.all.new_picklistname.DataValue.style.display=‘’;

www.proteans.com
5. Changing the Requirement Level of an attribute means setting the priority Level
crmForm.SetFieldReqLevel(‘attributename’,1);
Now the above code will make the attribute as mandatory field in the form . So the user cannot skip
this field blank.
Here ‘1’ means mandatory that is business required .Similarly we have other options like 0 and 2 for
no constraints and Business Recommended .

Window.Opener
When Microsoft Dynamics CRM forms are opened in relation to another record you can access the other
record by using the window.opener method. This is also true if the page is opened by using a button
configured in isv.config for the taskbar of the parent record.
Basically this can be used on the events that are present in the crm like onLoad and OnSave events .
Example:-
if (crmForm.FormType == 1)
{
if (window.opener) {
var oParentCrmForm = window.opener.document.all.crmForm;
if (oParentCrmForm && oParentCrmForm.ObjectTypeCode == 1) {
var sAccountName = oParentCrmForm.all.name.DataValue;
crmForm.all.subject.DataValue = "Account: " + sAccountName;
}}}

www.proteans.com
Security Role: Privileges and access levels

In the above example we can access the account name from the task s form and assign it to the
subject field. But we should make sure that this code shoukld run only on a particular event . And
most preferably It should be an onLoad event.

Likewise similarly we can set the values of the account entity attributes from the related opened
window.

www.proteans.com
Object-based Security: Access Rights

Object-based security applies to individual instances of entities and is provided by using access
rights. The relationship between an access right and a privilege is that access rights apply only
after privileges have taken effect. An access right is granted to a user for a particular entity instance.
The following table describes the access rights that are provided in Microsoft Dynamics CRM 4.0

www.proteans.com
Object-based Security: Sharing Entity
Instances
Sharing Entity
Sharing provides the ability for users to allow other users or teams access to specific customer
information, which can be useful for sharing data with users that are assigned to roles that have only
the User access level.
Consider the following example:  
 Bob and Ted are both assigned the Salesperson role, which has User Read and Write access to
accounts  
 Ted owns Account B and shares Opportunity 1 with Bob, with Read rights
  Bob can now read Opportunity 1, but not Account B

www.proteans.com
Object-based Security: Sharing Entity
Instances
Capability Description
Share A user who has share privileges on a given entity type can share
instances of that type with any other user or team in Microsoft Dynamics
CRM.
Share rights To share an entity instance with another user, grant access rights (Read,
Write, Delete, Append, Assign, and Share) to the other user for that entity
instance. Access rights on a shared entity instance can be different for
each user with whom the entity instance is shared. However, you cannot
grant a user rights that he or she would not automatically have for that
type of entity based on the role assigned to that user. For example, when
you share an account with a user that does not have Read privileges on
accounts, the user will not be able to see that account.
Modify share Alter the rights granted to a shared entity instance after it has been
shared.
Remove share When you share an entity instance with another user or team, you can
stop sharing the instance at a later time. After you remove sharing for an
entity instance, the other user or team loses access rights to the instance.

www.proteans.com
Object-based Security: Assigning Entity
Instances
Assigning Entity
Anyone with Assign privileges on an entity instance can assign that object to another user. When an
entity instance is assigned to a new user.
 The new user becomes the owner of the entity instance and its related entity instances.
 The original user loses ownership of the entity instance but automatically shares it with the new
owner.

www.proteans.com
General CRM Settings
 Administration

 Business Management

www.proteans.com
General CRM Settings: Administration

Announcement
An announcement is a message that appears to all users on the home page of the Web application. Announcements are
owned by the organization.
Auto-Numbering
Contracts, cases, knowledge base articles, quotes, orders, invoices, and marketing campaigns are automatically
numbered by Microsoft Dynamics CRM. Microsoft Dynamics CRM automatically generates unique numbers for selected
record types, such as contracts and cases. If your organization has standard numbering formats, you can change the
default 3-character prefixes, and you can change how the numbers are constructed to match your organization.
Business Units
A business unit is a unit of the top-level organization. Business units can be parents of other business units (child
business units). The first business unit created for an organization is called the root business.
A business unit basically is a group of users. Large organizations with multiple customer bases often use multiple
business units to control data access and define security roles so that users can access records only in their own
business unit. Here you can Create new business units, Change a parent business unit and Disable a business unit.
Security Roles
Security roles are predefined groups of common privileges based on the types of tasks users perform.
Defined sets of privileges. The security role assigned to a user determines which tasks the user can perform and which
parts of the user interface the user can view. All users must be assigned at least one security role in order to access the
system

www.proteans.com
General CRM Settings: Administration

System Settings
Use can use the system setting to do the following settings on
 General
Set the options that affect how names and currency are displayed, how records are shared, and if attachments
are allowed.
 Formats
Set the regional format for how numbers, currency, time, and dates are displayed.
 E-mail
Set the options that control how e-mail is tracked and managed.
 Marketing
Set the options that control how marketing campaign e-mail features are managed.
 Customization
Set the prefix for the names of new entities.
 Outlook
Set the options for how users can synchronize with Microsoft Dynamics CRM for Outlook .
 Reporting
Specify report categories.
Team
A team is a group of users who share and collaborate on business records. A team can consist of members who all
report to one business unit or members who report to different business units. ). A team cannot be deleted after it is
created. However, you can deactivate a team by removing all the members from the team. To reactivate the team in the
future, just add new members to it.

www.proteans.com
General CRM Settings: Administration

Users
Manage a User's Record. Use this list to add, edit, enable and disable users ( People who have active user accounts in
Microsoft Dynamics CRM. ) , assign security roles and change business units or managers for a user. You can also
manage a user's working hours for scheduling.
Languages
Use this for settings to enable or disable the language

www.proteans.com
General CRM Settings: Business Management

Fiscal year
Fiscal year options affect the way in which your organization's data is stored in the Microsoft Dynamics CRM database.
Therefore, you can set the fiscal year options only once. You cannot change these settings after you have set them.
Facilities / Equipment
Facilities and equipment are types of resources i.e. Users that perform a service, or the equipment or facilities that are
required for a service. used to create selection rules for services.
Resource Groups
Use resource groups to group users, and equipment as part of the selection rules for a service .
Services
A service is a type of work performed for a customer by one or more resources. Services are schedulable activities. It
is used as part of a service .A service activity uses one or more resources to perform a service at a specific time and
place.
Subjects
Subjects are the Categories used in a hierarchical list to correlate and organize information. Subjects are used in the
subject tree to organize products, sales literature, and knowledge base articles. They are used in cases, sales literature,
products, and articles.
Currencies
Currencies determine the prices for products in the product catalog and the cost of transactions, such as sales orders.
You can add as many currencies as are necessary for your organization, but you cannot change the base currency after
it has been set.

www.proteans.com
General CRM Settings: Business Management

Sites
The site is a business location to which resources are assigned. A site is used to ensure that all resources required for a
service are in the same physical location. It determines where a can be provided. Sites are used for service scheduling.
Sales Territories
A segment of an organization's market that is assigned to a salesperson or a group of salespeople. You can assign one
sales territory per user.
Queues
Holding containers for activities that need to be completed. There are queues that contain cases and activities in the
Workplace, and queues of articles in the knowledge base. There are two standard queues In Progress and Assigned.
Business Closures
A period of time that the entire business is closed and service activities cannot be made. You can use a business closure
to block when someone can schedule an appointment or service.
Relationship Roles
Relationship roles represent standard labels that can be used to identify relationships that exist between accounts,
contacts, and opportunities.

www.proteans.com

You might also like