How to define hidden column in Xrm grid - dynamics-crm

Is there a way how to include hidden column in xrm grid/view ?
Say I have saved query definition like:
<savedquery>
<savedqueryid>{...}</savedqueryid>
<layoutxml>
<grid name="resultset" jump="name" select="1" icon="1" preview="1">
<row name="result" id="entityid">
<cell name="name" width="200" />
<cell name="statuscode" width="100" />
</row>
</grid>
</layoutxml>
<querytype>0</querytype>
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="entity">
<attribute name="name" />
<attribute name="statuscode" />
</entity>
</fetch>
</fetchxml>
</savedquery>
What I'm after is having the column in grid accessible via client api - as it drives the ribbon logic
var allSelectedRows = gridContext.getGrid().getSelectedRows().forEach((row) => {
// this doesn't work if grid doesn't contain statuscode column
let status = row.data.entity.attributes.get("statuscode");
});
Without actually showing the column in UI.

Technically not possible, unfortunately. As there is no property to set hidden columns, also not advisable to do/read unsupported DOM elements access.
You can use SelectedControlSelectedItemIds to pass as a parameter to custom JavaScript and then you can pull the needed column like statuscode from server to do validation.

Related

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 365 subject tree not updating case dropdown

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.

How to recover the deleted the “Quick Find View”. in MS Dynamics CRM

IF you delete the Quick Find View of an Entity,
How to recover it please follow the below instructions
Solution:
First create a view and get his GUID, save in notepad, and delete the
view.
Create a solution, Import the selected entity from which you
deleted the “Quick Find View” and Export it. Open Customization.xml and add the XML to the following path.
XML Path : ImportExportXml/Entities/Entity/SavedQueries
<savedquery>
<IsCustomizable>1</IsCustomizable>
<CanBeDeleted>0</CanBeDeleted>
<isquickfindquery>1</isquickfindquery>
<isprivate>0</isprivate>
<isdefault>1</isdefault>
<returnedtypecode>Entitytypecode</returnedtypecode>
<savedqueryid>View Guid</savedqueryid>
<layoutxml>
<grid name="resultset" object=" Entitytypecode " jump="FieldName" select="1" icon="1" preview="1">
<row name="result" id="Entity Primary Key ">
<cell name="name" width="300" />
<cell name="createdon" width="125" />
</row>
</grid>
</layoutxml>
<querytype>4</querytype>
<fetchxml>
<fetch version="1.0" mapping="logical">
<entity name="Entity Name">
<attribute name="Entity Primary Key" />
<attribute name="name" />
<attribute name="createdon" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
</filter>
<filter type="or" isquickfindfields="1">
<condition attribute="name" operator="like" value="{0}" />
</filter>
</entity>
</fetch>
</fetchxml>
<IntroducedVersion>1.0</IntroducedVersion>
<LocalizedNames>
<LocalizedName description="Quick Find Active" languagecode="1033" />
</LocalizedNames>
</savedquery>
Save the file.
Upload the Solution and Publish it.

fetchXml from CRM - is it possible to fetch just the "last" record for a linked entity?

I tried using top="1" and an order descending in the linked-entity element, and I still get back multiple records joined.
<fetch version="1.0" mapping="logical" >
<entity name="x" >
<attribute name="xid" />
<link-entity alias="d" top="1" name="t" from="xid" to="xid" link-type="outer">
...
<order attribute="xdate" descending="true" />
</link-entity>
</entity>
</fetch>
You can't limit the number of link entities returned. What you could do instead is make link-entity d the entity and entity x the link-entity so you can use top as it is intended.

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>

Resources