<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>platform &#8211; Hamza Siddiqui</title>
	<atom:link href="https://www.mhamzas.com/blog/tag/platform/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mhamzas.com</link>
	<description>4x Salesforce MVP &#124; 26x Certified &#124; Salesforce App &#38; System Architect</description>
	<lastBuildDate>Tue, 20 Dec 2022 12:31:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
<site xmlns="com-wordpress:feed-additions:1">233526040</site>	<item>
		<title>Get all Parent and child objects related to the current object</title>
		<link>https://www.mhamzas.com/blog/2022/12/15/get-all-parent-and-child-objects-related-to-the-current-object/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=get-all-parent-and-child-objects-related-to-the-current-object</link>
					<comments>https://www.mhamzas.com/blog/2022/12/15/get-all-parent-and-child-objects-related-to-the-current-object/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Thu, 15 Dec 2022 11:01:24 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[apex]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[platform]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3497</guid>

					<description><![CDATA[Many times you have to find the related objects either you do it the hardcode way or another. Here I am sharing an example of how you can dynamically get the Related either Parent or Child. The below examples are for the <br /><a href="https://www.mhamzas.com/blog/2022/12/15/get-all-parent-and-child-objects-related-to-the-current-object/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Many times you have to find the related objects either you do it the hardcode way or another. Here I am sharing an example of how you can dynamically get the Related either Parent or Child.</p>



<p class="wp-block-paragraph">The below examples are for the standard &#8220;Account&#8221; object. However, this will work for any other standard or custom object &#8211; don&#8217;t forget to add __c for the custom objects.</p>



<h2 class="wp-block-heading">Get All Parent objects.</h2>



<pre class="wp-block-code"><code>for(Schema.SobjectField strFld: Account.SobjectType.getDescribe().fields.getMap().Values())
{
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE)
    {
        system.debug('==parent object='+strFld.getDescribe().getReferenceTo());
    } 
}
</code></pre>



<h2 class="wp-block-heading">Get All Child objects.</h2>



<pre class="wp-block-code"><code>Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
for (Schema.ChildRelationship cr: R.getChildRelationships()) 
{
  system.debug('====child object==='+cr.getChildSObject());
}
</code></pre>



<h2 class="wp-block-heading">Getting Relationship Names</h2>



<pre class="wp-block-code"><code>Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
for (Schema.ChildRelationship cr: R.getChildRelationships()) 
{
  system.debug('====child object relation Name==='+cr.getRelationshipName());
}
</code></pre>



<p class="wp-block-paragraph">Source: https://salesforce.stackexchange.com/questions/117050/get-all-parent-and-child-objects-related-to-the-current-object<br>Credit: https://salesforce.stackexchange.com/users/18731/ratan-paul</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2022/12/15/get-all-parent-and-child-objects-related-to-the-current-object/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3497</post-id>	</item>
	</channel>
</rss>
