{Issue Resolution} Auto-follow a record enabled for Activity feeds in Dynamics CRM 2013/2015

Recently one of the requirement that was asked to one of my fellow community members was to auto-follow an opportunity record, once it is created.

Opportunity entity is automatically enabled for Activity feeds, so I will not get to those bits.Here is the code to achieve the same:

 

    //ID of the user for which auto-follow needs to be enabled

Guid userid = new Guid(“878D274D-8375-E411-80D0-AC162DB47C44”);

  //ID of the record for which auto-follow needs to be enabled

                    Guid pitch = new Guid(“D3B9BEBB-9076-E411-80D9-AC162DB46F8A”);

                    Entity postfollow = new Entity(“postfollow”);

                    postfollow.Attributes[“regardingobjectid”] = new EntityReference(“opportunity”, pitch);

                    postfollow.Attributes[“ownerid”] = new EntityReference(“systemuser”, userid);

                    Guid postfollowId = service.Create(postfollow);

 

I think it is a very useful piece of code, as there are not enough code samples on this feature.

Hope it helps!

 

 

               

Refreshing the Web Resource in CRM 2013.

Got asked this query and found solution from my old colleague.

Nishant Rana's Weblog

In one of our Entity’s Form we were using HTML Web Resource and this HTML web resource was showing values of the attributes in that form.

Now in CRM 2011, after we save the record the form reloads and so our web resource was picking up the new values saved.

However in CRM 2013, on save, as the form doesn’t reload, the values were not getting updated in the HTML Web Resource.

So the solution was to refresh the Web Resource using Jscript on the On Save event of the form.

Hope it helps.

View original post

{ZERO CODE DEVELOPMENT}Restrict user to add notes to inactive entity: Dynamics CRM 2013/2015

When a record is inactive, changes to most fields in record are locked. Still, there are some actions which are out of box allowed like adding activities, notes, etc.

I often have had this scenario.

Here is a simple workflow solution to solve this problem. I have taken example of Contact record and Notes.

Step 1: Create a workflow on Create of Notes (It should be synchronous):

clip_image002

Step 2: Put a check condition to check parent regarding status:

clip_image004

clip_image006

Step 3: Stop the workflow with cancelled, if this condition is met true:

clip_image008

Set Error Message in Properties:

clip_image010

Now let’s see this in action:

clip_image012

Hope it helps!

{ZERO CODE DEVELOPMENT} Creating Posts when Entity is updated in Dynamics CRM 2013/2015

Activity feeds are enabled for some out of box entities automatically in CRM for specific actions. Recently there was a query on CRM community how to be able to create posts when an Entity is updated.

Solution: Create an out of box workflow on entities you want to have auto post on updates.

Step 1: Taking example of lead entity, create a workflow on update of lead entity:

clip_image002

Note: It is not necessary to create synchronous workflow.

Step 2: All fields must be selected in Records field change (If you want specific, you can update specific):

clip_image004

Step 3:

Create Post in the processing step:

clip_image006

clip_image008

Step 4: Activate this, follow a lead record (Follow button via ribbon). Your changes will now start appearing in What’s new area as well as posts area on the record:

What’s new area below:

clip_image010

Posts on Record’s wall :

clip_image012

Hope it helps!

Get and Set ‘Partylist’ fields using Jscript

This was a recent query asked to me. Adding a solution done by my old colleague Rajeev here:

Rajeev Pentyala - Microsoft Power Platform

If you observe “Required” lookup field on an ‘Appointment’ form, you can choose more than one Accounts or Contacts or Users.

Though it looks like a normal lookup field actually it’s a field of type ‘Party list’.

Party List :-

  • Party List is a data type in CRM, using which you can set more than one records of an entity for a single field.
  • Part List type field, renders as Lookup on the form, but it works as multi select lookup.
  • We can’t create a custom party list fields.

For example,

  • In the ‘Appointment’ entity field “Required” is a ‘Party List’ type
  • We can select multiple records of different type (i.e., Accounts, Users, Contacts…)

Partylist Type

Below is Jscript to Get or Set ‘Partylist’

function getPartyList() {

var partyRequired = Xrm.Page.getAttribute(“requiredattendees”);

var attendees = party.getValue();

for (var indxAttendees = 0; indxAttendees < attendees.length; indxAttendees++) {

// User

if (attendees[indxAttendees].type == 8) {

alert(“Attendee is User; Id…

View original post 93 more words

{DYNAMICS CRM 2015}Calculate ROLLUP FIELD PROGRAMATICALLY

Retrieve a calculated rollup field value immediately

Rollup attributes support a CalculateRollupField message that developers can use to calculate a rollup attribute value on demand. The request and response, along with the members, are shown in the following table.

Request/Response
Members

CalculateRollupFieldRequest

Target: EntityReference for the record.

FieldName: String representing the logical name of the attribute.

CalculateRollupFieldResponse

Entity: Entity containing the rollup attribute and the supporting <attribute SchemaName>_Date and <attribute SchemaName>_State attributes.

This message is a synchronous operation for just the attribute identified in the request. If the value of that record is included as part of other rollup fields, the values of those fields won’t take the possible value change caused by calling this method into consideration until the regularly scheduled asynchronous jobs that perform those calculations occur.

Source: Click here

Hope it helps!

Tools developed by me on Dynamics CRM

1. https://jscriptdependencycheckerdynamicscrm.codeplex.com/

2. https://userclonerfordynamicscrm.codeplex.com/

3. https://securityrolebrowserforcrm.codeplex.com/

4. https://optionsetcreator.codeplex.com/

5. https://dynamicsofdynamicscrm.wordpress.com/2014/10/08/erd-generator-for-dynamics-crm-20112013/

6. https://dynamicsofdynamicscrm.wordpress.com/2014/11/17/script-search-utility-for-dynamics-crm-20112013/

7. https://dynamicsofdynamicscrm.wordpress.com/2014/12/12/utilitycrm-script-helper-for-dynamics-crm-20132015/

8. https://dynamicsofdynamicscrm.wordpress.com/2014/05/06/read-option-set-textvalue-at-one-go-crm-2013/

Hope it helps!

{New Information}CRM 2013 vs CRM 2015 some navigation and colour changes to notice

There are always some changes when Microsoft changes versions. This are slowly noticed by the Consultants and end-users.

Few below which I noticed:

· Colours of Business Process Flow Area on Forms have changed:

CRM 2013:

image

CRM 2015:

image

· Navigation changes for Security Area from Administration area for Teams, Security Roles, Users etc.:

CRM 2013: Navigate to Settings->Administration

image

CRM 2015: Navigate to Settings->Security

image

Note: Standard Administration functions are still under Administration Panel:

image

Hope it helps!