Dynamics 365 subject tree not updating case dropdown - dynamics-crm

When I update subject tree with new subjects or change subjects, I do not see it reflected in the case subject dropdown. I can go back into the subject tree and I see my changes are there and saved.
How do I get my Subject tree changes to show in the case subject dropdown?

Make sure you don't have any custom subject attribute, looking at the native subject tree relation in incident.
I will start digging the subject in XrmToolbox - FetchXml Builder for any discrepancy in data like featuremask (need to be 1). We cannot check this in Adv.Find as Subject is not searchable, also if you are in on-premise do the SQL way.
<fetch top="50" >
<entity name="subject" >
<attribute name="description" />
<attribute name="featuremask" />
<attribute name="subjectid" />
<attribute name="versionnumber" />
<attribute name="modifiedby" />
<attribute name="createdby" />
<attribute name="modifiedon" />
<attribute name="title" />
<attribute name="createdon" />
<attribute name="organizationid" />
<attribute name="parentsubject" />
</entity>
</fetch>

I was having this exact same issue. I added a couple of new subjects and they weren't appearing on the Case form. To resolve this I went to: Settings > Customizations > Customize the System. I then published all customizations and the new subjects started appearing on the Case form.

Related

Filter users by type Dynamics 365

I am trying to exclude App Users from a view in Dynamics 365 CRM. The fetch xml is very simple:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="systemuser">
<attribute name="fullname" />
<attribute name="businessunitid" />
<attribute name="title" />
<attribute name="address1_telephone1" />
<attribute name="positionid" />
<attribute name="systemuserid" />
<order attribute="fullname" descending="false" />
<filter type="and">
<condition attribute="type" operator="ne" value="App User" />
</filter>
</entity>
</fetch>
I need to place a filter in my query like this seudo code: <condition attribute="type" operator="ne" value="App User" />, sort of a field that allows me to filter by user type. Is there any field that could deterministically say that a user is an app user?
Typically, Non-interactive App user will be created with the attribute Access mode = 4 in system user entity. So this should work.
<condition attribute="accessmode" operator="ne" value="4" />

How can I get 'which updated fields can trigger to Dynamics CRM workflow'?

I have a custom workflow activity.
The workflow has been triggered by one of 10 specific fields updated.
I need these 10 fields what are they in my custom workflow. Is there any way I can get this information in custom workflow?
Edited After Aron's comment:
I try Aron's solution. It works, but some fields are missing.
For example, I have 7 fields (include the address field) to trigger my workflow as below.
But TriggerOnUpdateAttributeList has only 4 fields as below.
The Workflow entity has a field called TriggerOnUpdateAttributeList which contains what you're looking for.
One way to access it would be a FetchXML query:
<fetch top="1" >
<entity name="workflow" >
<attribute name="name" />
<attribute name="primaryentity" />
<attribute name="triggeronupdateattributelist" />
<filter>
<condition attribute="name" operator="eq" value="My Workflow" />
<condition attribute="triggeronupdateattributelist" operator="not-null" />
</filter>
</entity>
</fetch>
In the result, the TriggerOnUpdateAttributeList contains a comma separated list of the logical names of the fields:
<result>
<name>My Workflow</name>
<primaryentity name="" formattedvalue="2">2</primaryentity>
<triggeronupdateattributelist>firstname,lastname,parentcustomerid</triggeronupdateattributelist>
</result>

Dynamics - How to get all appointments that for a specific user attends by Web Api

In Dynamics CRM, I'm trying to get all the appointments where a specific user is an attendee, using Web API. I know that I have to deal with Appointment entity and ActivityParty with activitypartytypemask equals 9 but really cannot figure out how to make it. How can identify the attendee ?
You can use FetchXml for your purpose. Check following Fetch:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="appointment">
<attribute name="subject" />
<attribute name="statecode" />
<attribute name="scheduledstart" />
<attribute name="scheduledend" />
<attribute name="regardingobjectid" />
<attribute name="activityid" />
<link-entity name="activityparty" from="activityid" to="activityid" alias="aa">
<filter type="and">
<condition attribute="participationtypemask" operator="in">
<value>6</value>
<value>5</value>
</condition>
<condition attribute="partyid" operator="eq" value="{9CE2BF21-408B-E611-80F3-C4346BAC7ABC}" />
</filter>
</link-entity>
</entity>
</fetch>
Using provided FetchXml and WebApi you should get the result you wanted. Url should look like following:
[Server Base Url]/api/data/v8.2/appointments?fetchXml=%3Cfetch%20version%3D%221.0%22%20output-format%3D%22xml-platform%22%20mapping%3D%22logical%22%20distinct%3D%22true%22%3E%3Centity%20name%3D%22appointment%22%3E%3Cattribute%20name%3D%22subject%22%20%2F%3E%3Cattribute%20name%3D%22statecode%22%20%2F%3E%3Cattribute%20name%3D%22scheduledstart%22%20%2F%3E%3Cattribute%20name%3D%22scheduledend%22%20%2F%3E%3Cattribute%20name%3D%22regardingobjectid%22%20%2F%3E%3Cattribute%20name%3D%22activityid%22%20%2F%3E%3Clink-entity%20name%3D%22activityparty%22%20from%3D%22activityid%22%20to%3D%22activityid%22%20alias%3D%22aa%22%3E%3Cfilter%20type%3D%22and%22%3E%3Ccondition%20attribute%3D%22participationtypemask%22%20operator%3D%22in%22%3E%3Cvalue%3E6%3C%2Fvalue%3E%3Cvalue%3E5%3C%2Fvalue%3E%3C%2Fcondition%3E%3Ccondition%20attribute%3D%22partyid%22%20operator%3D%22eq%22%20value%3D%22%7B9CE2BF21-408B-E611-80F3-C4346BAC7ABC%7D%22%20%2F%3E%3C%2Ffilter%3E%3C%2Flink-entity%3E%3C%2Fentity%3E%3C%2Ffetch%3E
This article contains additional details.

View Showing Accounts that don't have contact

I want to create two views.
- One view showing all accounts having contacts. It is easy. I don't have any issue with this.
- Second View Showing All Accounts don't have any contact.
As we can't specify such condition for second view in advance find. Is there any way we can achieve this using Views?
I don't want to create SSRS report or any custom Development.
Please let me know if this is achievable.
You can achieve this only by modifying the Account entity customization xml.
Create a new (system) view for Account and name it "Active Accounts without Contacts".
Create a (unmanaged) solution for export and add the Account entity without any dependencies.
Export the solution and unpack the zip archive.
Open the customization.xml with the editor of your choice.
Modify the views FetchXml as follows:
before
...
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="account">
<attribute name="accountid" />
<order attribute="name" descending="false" />
</entity>
</fetch>
</fetchxml>
<IntroducedVersion>1.0.0.0</IntroducedVersion>
<LocalizedNames>
<LocalizedName description="Active Accounts without Contacts" languagecode="1033" />
</LocalizedNames>
<Descriptions>
<Description description="Active Accounts without Contacts" languagecode="1033" />
</Descriptions>
...
after
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="account">
<attribute name="accountid" />
<order attribute="name" descending="false" />
<link-entity name="contact" from="parentcustomerid" to="accountid" link-type="outer"/>
<filter type="and">
<condition attribute="parentcustomerid" operator="null" />
</filter>
</entity>
</fetch>
</fetchxml>
<IntroducedVersion>1.0.0.0</IntroducedVersion>
<LocalizedNames>
<LocalizedName description="Active Accounts without Contacts" languagecode="1033" />
</LocalizedNames>
<Descriptions>
<Description description="Active Accounts without Contacts" languagecode="1033" />
</Descriptions>
...
Finally, re-package the solution, import and publish.
I could not get this to work, and after quite a bit of "tinkering" altered the fetchxml as follows and it works! I basically moved the filter to before the link-entity detail. This is on CRM2013 with Rollup 1.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="account" >
<attribute name="address1_city" />
<filter type="and" >
<condition entityname="contact" attribute="parentcustomerid" operator="null" />
</filter>
<link-entity name="contact" from="parentcustomerid" to="accountid" link-type="outer" />
<attribute name="primarycontactid" />
<order attribute="name" descending="false" />
<attribute name="telephone1" />
<attribute name="accountid" />
</entity>
</fetch>

Can you write a single FetchXML query to get 1:many relationship?

Is it possible to write a single FetchXML query that gets a root entity and multiple children? All I've been able to do is 1:1.
James Wood is correct. Fetch XML is recursive so by using the link entity you can get the information you want.
For example, the following is valid:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="account">
<attribute name="name" />
<attribute name="primarycontactid" />
<attribute name="telephone1" />
<attribute name="accountid" />
<order attribute="name" descending="false" />
<link-entity name="contact" from="parentcustomerid" to="accountid" alias="aj">
<attribute name="firstname" />
<attribute name="lastname" />
<attribute name="telephone1" />
<link-entity name="businessunit" from="businessunitid" to="owningbusinessunit" alias="ak">
<attribute name="name" />
<attribute name="address1_line1" />
<attribute name="address1_line2" />
<attribute name="address1_line3" />
<filter type="and">
<condition attribute="name" operator="not-null" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
If your question really is "Is it possible to write a single FetchXML query that gets a SINGLE root entity and multiple children" then the answer is unfortunately no. However if you are able to handle duplicates of root data (For example using the Grouping functionality of an SSRS report) then what you require is entirely possible
Unless I've misunderstood the question this is very possible.
So for example you want to find all the contacts related to a given account. This is represented in Crm by the Parent Customer Lookup on the contact to the account.
<fetch mapping="logical" count="100" version="1.0">
<entity name="account">
<attribute name="name" />
<link-entity name="contact" from="parentcustomerid" to="accountid">
<attribute name="fullname" />
</link-entity>
</entity>
</fetch>
Which gives you a result set that looks like this:
<resultset morerecords="0" paging-cookie="<cookie page="1"><accountid last="{E704FAD6-2D4B-E111-9FED-00155D828444}" first="{AD912122-6B3C-E111-9B37-00155D828444}" /></cookie>">
<result>
<name>RGD Mining Inc</name>
<accountid>{E704FAD6-2D4B-E111-9FED-00155D828444}</accountid>
<accountid.fullname>Bill Miner</accountid.fullname>
</result>
<result>
<name>RGD Mining Inc</name>
<accountid>{E704FAD6-2D4B-E111-9FED-00155D828444}</accountid>
<accountid.fullname>Green</accountid.fullname>
</result>
</resultset>
No, it is not possible.
I'm happy to report that it is possible. I have a solution that worked well for me.
The only caveat is that if you have multiple child accounts you will get multiple results for the parent. For example:
parent 1: child 1
parent 2: child 1
parent 2: child 2
This means that you would then have to run the results through a sorting function, to get either all the children under parents in a multi dimensional array, or get all the accounts as unique entries in a flat array.
Also, this only goes down one level. If your hierarchy is multi-level, this code would need to be modified.
<fetch distinct="false" mapping="logical">
<entity name="account">
<attribute name="name" />
<link-entity name="account" alias="childaccount" to="accountid" from="parentaccountid" link-type="outer">
<attribute name="name" alias="childname" />
</link-entity>
</entity>
</fetch>

Resources