Dynamics CRM 2015 - Retrieve all Contact that are in any way connected to Opportunity - fetchxml

I need to present all contact that have connection to opportunity in dialog. So when some opportunity has Sales Team, Stakeholders, Owners, etc. Something like Active Connection Associate View. I need a FetchXml or other ways to find all the Contact that are in any way connected to current opened Opportunity.

Your fetchXML query will look quite like this :
<fetch mapping='logical' version='1.0'>
<entity name='myentity'>
<filter>
<condition attribute='myentityid' operator='eq' value='myvalue' />
</filter>
<link-entity name='secondentity' from='stsr_materialid' to='stsr_material_casinglookup' alias='c' link-type='outer'>
<attribute name='stsr_name' />
<attribute name='stsr_code_aisi' />
<attribute name='stsr_code_astm' />
<attribute name='stsr_code_din' />
<attribute name='stsr_code_e' />
<attribute name='stsr_code_en' />
</link-entity>
If you need more help, please provide more context.

Related

How to fix Http request failure when trying to query the Microsoft Dataverse Web API from Power Automate?

I'm trying to retrieve all the users and their roles across some environments in my Office 365 tenant using a Power Automate flow, but when I'm trying to query the Dataverse Web API either with OData or fetchXml, I always get the same error:
At this point I don't have any clue on how to fix it, if anyone could point me in the right direction I would really appreciate it. I also tried this in postman and it works without problem.
Thanks for your help.
I'm adding some extra information below.
URI
https://someorg.crm2.dynamics.com/api/data/v9.2/systemusers
Headers
{
"Accept": "application/json",
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Prefer": "odata.include-annotations=\"*\"",
"If-None-Match": "null",
"Content-Type": "application/json; charset=utf-8"
}
Query
<fetch top="1000">
<entity name="systemuser">
<attribute name="fullname" />
<attribute name="domainname" />
<link-entity name="systemuserroles" from="systemuserid" to="systemuserid" intersect="true">
<link-entity name="role" from="roleid" to="roleid" intersect="true">
<attribute name="name" />
<attribute name="roleid" />
</link-entity>
</link-entity>
</entity>
</fetch>

Execution of Fetch XML using Web API Dynamics 365

I am using this approach for paging using Fetch XML within Web API.
Web API works perfect when we use simple fetch and it returns pagging cookie along with results if there are more records but when we use complex(where we have link entities) Fetch XML it returns paging cookie but empty e.g.:
<b><cookie pagenumber="2" pagingcookie="" istracking="False" /></b>
Here you can see we have nothing in pagingcookie.
Fetch XML used for query:
<fetch mapping="logical" version="1.0" output-format="xml-platform" count="10" page="1" >
<entity name="invoicedetail" >
<attribute name="invoicedetailid" />
<attribute name="uomid" />
<attribute name="quantity" />
<attribute name="manualdiscountamount" />
<attribute name="priceperunit" />
<attribute name="extendedamount" />
<filter>
<condition entityname="invoice" attribute="customerid" operator="eq" value="{5A8F8B46-2443-E511-80E3-3863BB351E10}" />
</filter>
<link-entity name="invoice" from="invoiceid" to="invoiceid" >
<attribute name="invoiceid" />
<attribute name="invoicenumber" />
<attribute name="description" />
<attribute name="totalamount" />
<order attribute="ss_postingdate" descending="true" />
</link-entity>
</entity>
</fetch>
If we remove linked entity it starts giving the exact paging cookie in the response that can be get using #Microsoft.Dynamics.CRM.fetchxmlpagingcookie.
Is there any way to get the exact paging cookie in complex scenarios?
I've seen this happen before in the standard organization service. I would suggest just paging without the paging cookie - this resolved the issue for me in the organization service.
E.g. <fetch mapping="logical" page="1" count="50">

how to get a cross Joins in Fetch XML queries in CRM2011?

1.-First Time I do Queries as it then I dont know how to get a cross join
2.-I understand this example is a inner join isn't it? I take it for this line "from="accountid" to="customerid"" this sees as a Inner Join
then how would it be a cross join?
3.- I copied this example on http://mscrmshop.blogspot.mx/2012/09/outer-joins-in-fetch-xml-queries-in.html
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="opportunity">
<attribute name="name" />
<attribute name="customerid" />
<attribute name="estimatedvalue_base" />
<order attribute="name" descending="false" />
<link-entity name="account" from="accountid" to="customerid" visible="false" link-type="outer" alias="accountid">
<attribute name="telephone1" />
</link-entity>
</entity>
</fetch>
Fetch XML does not support a cross Join.
There is another alternative solution suggested in the below link. Please see whether that can be useful for your case.
http://social.microsoft.com/Forums/en-US/e3ee734c-81d3-4277-b54f-c2e46bb20e0d/crm-2011-sql-cross-join-equivalent-fetchxml-in-report?forum=crmdevelopment

SSRS can't use "Required Attendees" in dataset?

I am creating report in SSRS for CRM. I have a table with Dataset for Appointment info and I noticed that it does not allow me to report on required attendees??? Is this true? If so is there a workaround around this? I basically want my report to show appointments details and of course who participated.
Any advice is much appreciated!
Below is the fetchXML I gathered from using Advanced Find in CRM 2013.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="appointment">
<attribute name="subject"/>
<attribute name="statecode"/>
<attribute name="scheduledstart"/>
<attribute name="activityid"/>
<attribute name="instancetypecode"/>
**<attribute name="requiredattendees"/>**
<order attribute="subject" descending="false"/>
<link-entity name="account" from="accountid" to="regardingobjectid" alias="ae">
<filter type="and">
<condition attribute="accountid" operator="eq" value="#name"/>
</filter>
</link-entity>
</entity>
</fetch>
To get this information you will have to create another one datasource and retrieve information from ActivityParty entity. All items like requiredattendees, optionalattendees in appointment, from, to, cc, bcc in email, e.t.c. are stored inside ActivityParty entity.

How to update specific XML attributes in SQL Server?

We are storing an XML document of all the different costs in SQL Server 2008 r2. Now, certain prices need to be update based on a formula.
One approach to this would be to:
Shred the XML and access the values.
Do the calculation
Now rebuild the XML structure.
Is this the only way to do it? Or is there an easier way where we can access the values on the fly and update the entire XML in one go? For this kind of scenario, what is the best approach?
Here is the sample of the XML:
<ItemAttributeData>
<Section ID="469919" TypeID="61000002">
<Attributes>
<Attribute ID="3870" UniqueID="1c71212b-8395-4b43-a44d-9a63374c8c99" VALUE="2" />
<Attribute ID="3569" UniqueID="c0b754d3-e03e-4d4a-9bc1-dcb11c04535b" VALUE="2" />
<Attribute ID="1592" UniqueID="2609b344-88b2-44d6-be20-07b634705c30" VALUE="2" />
</Attributes>
</Section>
<Section ID="469920" TypeID="61000001">
<Attributes>
<Attribute ID="3702" UniqueID="7cabf9e8-4f60-4e1e-afe5-75b153e8c5eb" VALUE="1000001649" />
<Attribute ID="3870" UniqueID="595f8e2c-bccb-4fcb-81d4-303fcb7d44c4" VALUE="2" />
<Attribute ID="3868" UniqueID="2226f6c6-380a-4195-98f7-c6deec84e4e8" VALUE="2" />
<Attribute ID="3754" UniqueID="bf936c3f-fa96-49b9-8a62-46fb7e0009d5" VALUE="1000001600" />
<Attribute ID="2204" UniqueID="bdc78784-86ad-4567-bc06-40896d603eaf" VALUE="1" />
<Attribute ID="3874" UniqueID="8728249f-5e60-4938-a60d-208426fe11c8" VALUE="1" />
</Attributes>
</Section>
<Section ID="469921" TypeID="61000001" />
</ItemAttributeData>
You can use non standard XML update command replace value of. Like
DECLARE #myDoc xml
SET #myDoc = '<Root>
<Location LocationID="10"
LaborHours=".1"
MachineHours=".2" >Manu steps are described here.
<step>Manufacturing step 1 at this work center</step>
<step>Manufacturing step 2 at this work center</step>
</Location>
</Root>'
--SELECT #myDoc
SET #myDoc.modify('
replace value of (/Root/Location[1]/#LaborHours)[1]
with (
if (count(/Root/Location[1]/step) > 3) then
"3.0"
else
"1.0"
)
')
SELECT #myDoc