Here is the SQL query and FetchXML to get merged Accounts.
--Get Merged Accounts SELECT FA.name,fa.masterid AS 'SubOrdinate Account',FA.masteraccountidname AS 'Master Account' FROM FilteredAccount (NOLOCK) FA WHERE Fa.merged=1 <fetch version='1.0' output-format='xml-platform' mapping='logical' no-lock='true' distinct='false'> <entity name='account'> <attribute name='name' alias='SubOrdinate_Account' /> <attribute name='masterid' alias='Master_Account' /> <filter> <condition attribute='merged' operator='eq' value='1' /> </filter> </entity> </fetch>
Here is the SQL query and FetchXML to get merged Contacts.
--Get Merged Contacts SELECT FC.fullname AS 'SubOrdinate Contact',FC.mergedname AS 'Master Contact' FROM FilteredContact (NOLOCK) FC WHERE FC.merged=1 <fetch version='1.0' output-format='xml-platform' mapping='logical' no-lock='true' distinct='false'> <entity name='contact'> <attribute name='name' alias='SubOrdinate_Contact' /> <attribute name='masterid' alias='Master_Contact' /> <filter> <condition attribute='merged' operator='eq' value='1' /> </filter> </entity> </fetch>
Here is the SQL query and FetchXML to get merged Leads.
--Get Merged Leads SELECT FL.fullname AS 'SubOrdinate Lead',FL.mergedname AS 'Master Lead' FROM FilteredLead (NOLOCK) FL WHERE FL.merged=1 <fetch version='1.0' output-format='xml-platform' mapping='logical' no-lock='true' distinct='false'> <entity name='lead'> <attribute name='name' alias='SubOrdinate_Lead' /> <attribute name='masterid' alias='Master_Lead' /> <filter> <condition attribute='merged' operator='eq' value='1' /> </filter> </entity> </fetch>
Good info, thanks.
How to fetch leads from CRM
This is the code i am using but not working for me..
GetHeaderOnline ( $username, $password, $url );
// End CRM Online
// CRM On Premise – IFD
// $url = “https://org.domain.com/”;
// //Username format could be domain\\username or username in the form of an email
// $username = “username”;
// $password = “password”;
// $crmAuth = new CrmAuth();
// $authHeader = $crmAuth->GetHeaderOnPremise($username, $password, $url);
// End CRM On Premise – IFD
$userid = WhoAmI ( $authHeader, $url );
if ($userid == null)
return;
$name = CrmGetUserName ( $authHeader, $userid, $url );
print $name;
function WhoAmI($authHeader, $url) {
$xml = “
“;“;$xml .= “”;
$xml .= “”;
$xml .= ““;
$xml .= ““;
$xml .= “WhoAmI“;
$xml .= “”;
$xml .= “”;
$xml .= “
$executeSoap = new CrmExecuteSoap ();
$response = $executeSoap->ExecuteSOAPRequest ( $authHeader, $xml, $url );
$responsedom = new DomDocument ();
$responsedom->loadXML ( $response );
$values = $responsedom->getElementsbyTagName ( “KeyValuePairOfstringanyType” );
foreach ( $values as $value ) {
if ($value->firstChild->textContent == “UserId”) {
return $value->lastChild->textContent;
}
}
return null;
}
function CrmGetUserName($authHeader, $id, $url) {
$xml = ‘
false
leadid
subject
statuscode
statuscode
Equal
1
And
false
lead
0
0
false
false
‘;
$executeSoap = new CrmExecuteSoap ();
$response = $executeSoap->ExecuteSOAPRequest ( $authHeader, $xml, $url );
echo “