Sunday, 19 June 2022

 getRelatedListsInfo

Use this wire adapter to get the metadata for RelatedLists in an object’s default layout.

Parameters

  • parentObjectApiName—(Required) The API name of a parent object that you want to get related lists for, like an Account.
  • recordTypeId—(Optional) The ID of the parent record type.


HTML

<template>
    <lightning-card title="Related List of Account">
        <template if:true={relatedLists}>
            <div class="slds-m-around_medium">
                <template for:each={relatedLists} for:item="relatedList">
                    <p key={relatedList.label}>
                        {relatedList.label}
                    </p>
                </template>
            </div>
        </template>
    </lightning-card>
</template>


JS

import { LightningElement,wire} from 'lwc';
import { getRelatedListsInfo } from 'lightning/uiRelatedListApi';
export default class GetRelatedListDetails extends LightningElement {
    error;
    relatedLists;
    @wire(getRelatedListsInfo, {
        parentObjectApiName: 'Account',
       
    })listInfo({ error, data }) {
        if (data) {
            this.relatedLists = data.relatedLists;
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.relatedLists = undefined;
        }
    }
}

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
         <target>lightning__RecordPage</target>
    </targets>

</LightningComponentBundle>

RESULT:





 getRelatedListRecords

Use this wire adapter to get RelatedList records.

Parameters

  • parentRecordId—(Required) The ID of the parent record that you want to get related lists for, like an Account ID.
  • relatedListId—(Required) The API name of a related list object, like Contacts, Opportunities, or Cases.
  • fields—(Optional) The API names of the related list’s column fields.
  • optionalFields—(Optional) The API names of additional fields in the related list.
  • pageSize—(Optional) The number of list records to return per page.
  • sortBy—(Optional) An array of field API names to sort the related list by. Accepts only one value per request.
  • where—(Optional) The filter to apply to related list records, in GraphQL syntax.


HTML

<template>
    <lightning-card title="Opportunity Related List Records">
        <template if:true={records}>
            <div class="slds-m-around_medium">
                <template for:each={records} for:item="rec">
                    <p key={rec.fields.Id.value}>
                        {rec.fields.Id.value} -  {rec.fields.Name.value}
                    </p>
                </template>
            </div>
        </template>
    </lightning-card>

</template>

JS
import { LightningElement,wire} from 'lwc';
import { getRelatedListRecords } from 'lightning/uiRelatedListApi';
export default class GetRelatedListRecords extends LightningElement {
    error;
    records;
    @wire(getRelatedListRecords, {
        parentRecordId: '0010I00002Zq6IMQAZ',
        relatedListId: 'Opportunities',
        fields: ['Opportunity.Id','Opportunity.Name']
    })listInfo({ error, data }) {
        if (data) {
            this.records = data.records;
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.records = undefined;
        }
    }
}

XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
         <target>lightning__RecordPage</target>
    </targets>

</LightningComponentBundle>


RESULT




 getRelatedListInfo

Use this wire adapter to get the metadata for RelatedList.

  • parentObjectApiName—(Required) The API name of a parent object that you want to get related lists for, like an Account.
  • relatedListId—(Required) The API name of a related list object such as Contacts, Opportunities, or Cases.
  • recordTypeId—(Optional) The ID of the parent record type. If not provided, the default record type is used.

This code example fetches the metadata for the Opportunity-related list in the Account object, then iterates through the list of display columns.


HTML

<template>
    <lightning-card title="Get Opportunity Related List Information">
        <template if:true={displayColumns}>
            <div class="slds-m-around_medium">
                <template for:each={displayColumns} for:item="info">
                    <p key={info.fieldApiName}>
                        {info.label}
                    </p>
                </template>
            </div>
        </template>
    </lightning-card>
</template>

JS

import { LightningElement,wire } from 'lwc';
import { getRelatedListInfo } from 'lightning/uiRelatedListApi';
export default class GetRelatedListInfo extends LightningElement {
    error;
    displayColumns;
    @wire(getRelatedListInfo, {
        parentObjectApiName: 'Account',
        relatedListId: 'Opportunities',
    })listInfo({ error, data }) {
        if (data) {
            console.log('data',JSON.stringify(data))
            this.displayColumns = data.displayColumns;
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.displayColumns = undefined;
        }
    }
}

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
         <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

RESULT








Get Related List Record Count

Use this wire adapter to get the RelatedList record count.

 This code example fetches the record count for a related list.

  • parentRecordId—(Required) The ID of the parent record that you want to get related lists for, like an Account ID.
  • relatedListId—(Required) The API name of a related list object such as Contacts, Opportunities, or Cases.

HTML

<template>
    <lightning-card title="getRelatedListCount">
        <div class="slds-var-p-around_medium">
          <template if:true={responseData}>
            <div>No of opportunities in account related list - {responseData.count}</div>
          </template>
        </div>
      </lightning-card>
</template>

JS

import { LightningElement,wire} from 'lwc';
import {getRelatedListCount} from 'lightning/uiRelatedListApi';
export default class GetReleatedListCount extends LightningElement {
    responseData;
    error;
    @wire(getRelatedListCount, {
      parentRecordId:'0010I00002Zq6IMQAZ', // AccountId
      relatedListId:'Opportunities' //RelatedList object Name
    })listInfo({error, data}){
      if(data){
         this.responseData = data;
         this.error = undefined;
      }
      if(error){
        this.error = error;
        this.responseData = undefined;
      }
    }
  }
 

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
         <target>lightning__RecordPage</target>
    </targets>

</LightningComponentBundle>

RESULT




Saturday, 5 March 2022

        How to find who created the lightning web component 


 We can find aura and LWC in Setup > Quick find > Lightning Components. The Type column gives information on Aura/LWC. It provides CreatedBy, CreatedDate, and the LastModifiedDate of LWC and Aura.


 

Sunday, 20 February 2022

 

Unable to see the Reset Security Token option                 

There are a few different reasons the Reset Security Token feature may not be available. 

  1. IP Restrictions in the Login IP Ranges
  2. Network Access missing from Security Controls
  3. User Profile is Corrupted
  • IP Restrictions in the Login IP Ranges

          In order for the Reset My Security Token option to appear, you will need to remove the Login IP Ranges or change the User to a profile that does not have Login IP Ranges listed.
 
  • Network Access missing from Security Controls
    System administrators can confirm if Network Access is missing by following these steps:
  1. Go to Setup
  2. On the Quick Find box, enter Network Access.
  3. If you don't see the 'Network Access' link above, the system administrator can log a Case with Support to request the following features enabled for the organization:
  4. Login Challenge Enabled
  5. Login with API Token
  • User Profile is Corrupted
         If none of the previous scenarios are true try editing the User profile that's missing the security token and save it without making any modifications. This will reset the profile and might result in the token option being available.

If the information provided does not resolve the issue open a case with Salesforce Support for assistance.