Tuesday, June 19, 2018

Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible in dynamics. You will have to use the following class to get the calendar of a resource. ExpandCalendarRequest

An example of how the class can be used is given below.


ExpandCalendarRequest expandCalendarRequest = new ExpandCalendarRequest();
expandCalendarRequest.CalendarId = calendarId;
expandCalendarRequest.Start = startDate;
expandCalendarRequest.End = endDate;

ExpandCalendarResponse expandCalendarResponse = (ExpandCalendarResponse)organizationService.Execute(expandCalendarRequest);


CalenderId can be found from the resource record. Each resource is assigned a calendar. This is not visible on the form. But the field is there to be accessed.
Startdate and end date defines the time period we want to check the availability of the resource.

Response that comes in the form of ExpandCalendarResponse class. This returns timeinfo object. Properties of this class can be found in this link.

From the properties we can get the start time for each day and their availability. Availability can found from 2 properties. They are given below. 

  • TimeCode
    • Available - The time is available within the working hours of the resource. Value = 0.
    • Busy - The time is committed to an activity. Value = 1
    • Filter - Use additional filters for the time block such as service cost or service start time. Value = 3.
    • Unavailable - The time is unavailable. Value = 2.
  • Subcode
    • Appointment - A block of time that is already scheduled for an appointment. Value = 7.
    • Break - A block of time that cannot be committed due to a scheduled break. Value = 4.
    • Committed - A block of time that is committed to perform an action. Value = 2.
    • Holiday - A block of time that cannot be scheduled due to a scheduled holiday. Value = 5.
    • ResourceCapacity - Specifies the capacity of a resource for the specified time interval. Value = 10.
    • ResourceServiceRestriction - A restriction for a resource for the specified service. Value = 9.
    • ResourceStartTime - Specifies to filter a resource start time. Value = 8.
    • Schedulable - A schedulable block of time. Value = 1.
    • ServiceCost - An override to the service cost for the specified time block. Value = 12.
    • ServiceRestriction - Specifies that a service is restricted during the specified block of time. Value = 11.
    • Uncommitted - A block of time that is tentatively scheduled but not committed. Value = 3.
    • Unspecified - Specifies free time with no specified restrictions. Value = 0.
    • Vacation - A block of time that cannot be scheduled due to a scheduled vacation. Value = 6.

Product Bug in Dynamics 365 PSA for Business Closures

In Dynamics PSA we can add generic resources as team members to a project. When we add generic resources, resource requirement record and resource requirement detail record will be created in Dynamics.

When a resource requirement record is created, it takes the calendar of the generic resource in to consideration for resource requirement record. It will only create records for the days the resource will be working, resource duration worked on a day will be considered, start and end time of the resource will be taken in to consideration as well. 

If the resource is observing business closures and if the system contains business closure dates, they will be eliminated as well.

However with a recent patch business closure monitoring has been taken out and a resource requirement detail records is being created for such dates also. This is an issue as we cannot schedule such requirements against resources as they are observing business closures. I had a support ticket raised for this with Microsoft and they came back saying it is a bug in the product. They are going to fix this in the patch. This issue does not get raised if a project team member record is created directly for a named resource. 

Workarounds for this fr the time period

  • Use WBS structure to create project team members. (Ironically this creates records correctly)
  • Do a custom workflow to delete the records created for business closure dates
We have done the second option for a client, but waiting eagerly for the patch which is to be released very soon. Hopefully this will resolve the issue.



Work Hour Template in Dynamics 365

OOTB Dynamics comes with a default template which is called "Default work template". This probably will not be usable to most clients as they would have a different calendar for projects.

Dynamics gives the flexibility to add work hour templates as much as needed by clients. When you do create a new work template you have to specify a resource to it. This will make sure dynamics copies the resource calendar and creates a new calendar for the work hour template.


Please note after creating work hour template, even if you do change the resource of the template to a different resource it will not work. This is because the calendar of the work hour template will not change and will keep the calendar which was created at the beginning of the work hour template record. If you need to use a different calendar, you will have to create a new work hour template. That is the best way.




Resource Requirement Record For Project Team Members in Dynamics 365 PSA

Resource requirement is the record that dynamics users are using to schedule resources against projects. Just like in work orders, resource requirement record gets created when you create a project team member. 

It's important to know that this record does not get created when you directly assign a resource from a project as a project team member. That is from project team member section if you create a record giving an actual resource as the team member, a resource requirement record will not be created. This is, because there is no need for this as an actual resource has been created already and a dynamics user will not have to find resource for this.

When you create a generic resource, dynamics will create a resource requirement for that team member. This can be scheduled against resource from the schedule board. When you schedule a resource against such requirement, dynamics will create

  • Bookable Resource Header to summarise the work
  • Bookable Resource Booking record for each day, resource is schedule to be working
  • Update the fulfilled and remaining duration of the resource requirement record.

Monday, June 18, 2018

Team Based Security Privilege

In Dynamics, security privileges can be given to either a user record or a team record. If you want to create a user, not give him a security role and assign the user to a team which has enough security role to log in to Dynamics, it works fine. You can log in to Dynamics without any issues.

But the issue is when you try to access account records in Dynamics you get the following error. 

The strange thing here is, if you try to access accounts from an advanced find it will display a list of records. When you try to open a record, the record loads with the loading symbol. However the record doesn't load.

We believe there is a code that checks for security roles assigned to a user account to make sure at least one security role is assigned to a user. This is a bug in the code base. 

To over come this issue, what we did was simply create a new security role without assigning any privileges to it and assigned the role to the user. It actually worked for us :).

Sunday, June 17, 2018

Using SDK.Rest.retrieveRecord function

There are number of occasions where we have to access the fields of a lookup on a form and populate fields on the child form with the values that are coming from the parent lookup form fields. We use the sdk.rest.retreiverecord function to achieve this task with javascript.

For us to use this method the following javascript file has to be referenced before.


Then only we can call the function.

example of a function.

 var accountLookUp = Xrm.Page.getAttribute("msdyn_account").getValue();

        if (accountLookUp != null) {

            var Id = accountLookUp[0].id.replace("{", "").replace("}", "");

            SDK.REST.retrieveRecord(Id, "Account", "isv_ABC, isv_Country, isv_County", null, function (accountEntity) {

                

            }, function (error) {
                alert(error);
                alert(error.message);
            });
        }
        else {
      
        }

A lot of issues are arising with the fields to be retrieved. The field name is case sensitive and if it's not properly given then an error will appear stating "Error: Error : 400: : Type 'Microsoft.Crm.Sdk.Data.Services.Account' does not have a property named 'isv_abc'."

We can find this easily by doing the following. 

Paste the url of an account record in the browser and it will bring all the properties of the entity. You can find the field name from this list and refer it correctly. This has saved me a lot of time.

URL: https://crmresearch9.api.crm6.dynamics.com/XRMServices/2011/OrganizationData.svc/AccountSet(guid'ab132b6f-1101-e811-a832-000d3ab4f534')


The output will be like below. You will be able to pick the correct field name for the operation.



Wednesday, June 13, 2018

Hiding Dashboards in Dynamics 365

There are plenty of system dashboards that gets shipped with Dynamics 365. Some of these will have some use to a client, but some may not. If they are no use what the recommended option is to set the security permissions to the dashboards to determine which security roles can check them.



This can be done by opening the solution that contains the dashboards(If dashboards are not added to a solution, create a new solution and add the dashboards to proceed), select the dashboard that needs to be hidden and click enable security roles button. A pop up will open with security roles, and user will needs to select the security roles which should be able to check the dashboard. 





Recently I faced an issue with a client where after taking the privilege from dashboards by removing all security roles, client was able to see all of the dashboards. Client was a global admin and was the user who initiated creating of dynamics. All other users (Even system administrators were not able to check the dashboards). 

After checking this for sometime, we decided to remove the dashboards from the app they were using. You can do this by opening the app and then selecting the dashboards section from the app. There you can deselect the dashboards and then they will not appear under dashboards. This is what sorted the issue for us.

You can do this by going to the app section from the solution and opening the app. Then select the dashboard icon and deselect the dashboards.


Retrieving Calendar of a Bookable Resource in Dynamics

There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...