• Christian Schwabe 9
  • NEWBIE
  • 20 Points
  • Member since 2019
  • Salesforce Lead Developer
  • Colliers International Deutschland GmbH

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Hello everyone,

i try to build a custom lightning web component for a generic way to merge custom and standardobjects like the standard merge functionality for account, contact and leads.

Therefore i built two lwcs:
  • potentialDuplicates
  • mergeDuplicates
potentialDupplicates show the result for the duplicate rules (DuplicateRule), duplicate recordset (DuplicateRecordSet) and duplicate record item (DuplicateRecordItem) and looks like the following one:
https://ibb.co/gwp1fRk (https://ibb.co/jMRKJZL)

The first lwc (german language) show the salesforce standard "potential duplicates" component.
Below that - the highlighted one is my custom lwc.

The first screen (step1) looks like the following (Unfortunately I can't upload images - sorry for that):
https://ibb.co/MkJmmZT

After the selection and click on "Next" second screen (step2) appears and looks like the follwing:
https://ibb.co/xXQZDV1

On screen2 you have to choose the masterrecord and fields which has to move to masterrecord.

For comparison: In the standard potential duplicates the screen for step2 looks like the following:
https://ibb.co/5x7hfFv

I want to do this the exact same way. Here comes my problem: I didn't find a structure provided by apexcontroller that is able to iterate in a way to this list that columns and rows are syncron. The prepared structure of (selected) data records should be combined in such a way that they can be passed on to an apex controller, which then takes over the merge process.

One of my various solutions provide the following structure: Map<Id, List<Map<String, String>>>. Where key of map is the record id. The value of the outer map is a list with a map (key: apiname, value: fieldvalue). But this structure does not fit to the columns of screen2 and you can't iterate over map. Also a template expression doesn't allow NumericLiteral to access a specific index or key. It seems like everything has to be a list.

If I can realize this list of the selection, the processing of the data sets in Apex is only a child's play. Today I have worried all day about it and have not found an adequate solution.

Any suggestions for a provided structure of objects, arrays, maps to rule this target?

After i finished that components and everything works fine I am willing to publish the corresponding components.
Hi all,

in the documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation) a way is documented to preselect rows programmatically.
For this reason you should use "selected-rows"-attribut on lightning-datatable.

DOCUMENTATION

The selected-rows attribute enables programmatic selection of rows, which is useful when you want to preselect rows.
<lightning-datatable
    columns={columns}
    data={data}
    key-field="id"
    selected-rows={selectedRows}>
</lightning-datatable>
<lightning-button
    label="Select"
    onclick={handleSelect}>
</lightning-button>

To select a row programmatically, pass in the row key-field value.
// Load data via init handler first
// then handle programmatic selection
handleSelect() {
   const rows = ['a'];
   this.selectedRows = rows;
}

My component looks (simplfied) the following way:
export default class MergeDuplicates extends LightningElement {
    @track preSelectedRows = ['0011x00000KOMiJAAX'];
    
    [...]
}

My html-file (simplified) looks the following way:
<lightning-datatable
       key-field="Id"
       data={data}
       columns={columns}
       onrowselection={handleSelected}
       selected-rows={preSelectedRows}
       is-loading={tableLoadingState}>
</lightning-datatable>

My purpose: Preselect the current account, because the lwc is placed on a lightning record page for account.

My problem: Nothing happens. No checkbox is active.

One of my first ideas was the key-field. I changed it from "id" (lowercase) to "Id" (uppercase) but that don't solve the problem.

I don't know any other simpler way to test the preselect of rows for datatable than my example above.

Any suggestions?
Hi my friends,

currently I'm struggeling with the "current-step"-parameter on the lightning progress indictator (lightning-progress-indicator) in lightning web components.

I have a progress indicator:
<lightning-progress-indicator class="slds-align_absolute-center" current-step={currentStep} type="base" variant="base">
                                        <lightning-progress-step label="VIEW DUPLICATES" value=1></lightning-progress-step>
                                        <lightning-progress-step label="COMPARE RECORDS" value=2></lightning-progress-step>
                                        <lightning-progress-step label="CONFIRM MERGING" value=3></lightning-progress-step>
                                    </lightning-progress-indicator>

and a button that should switch the current step:
<lightning-button variant="brand" label="Next" title="Next" disabled={nextButtonDisabled} onclick={handleNext}></lightning-button>
and a corresponding eventhandler-method:
handleNext(){
        console.log('>>>handleNext in mergeDuplicates.js called.');
        console.log('>>>this.currentStep: ' + this.currentStep);

        switch (this.currentStep) {
            case 1:
                this.currentStep = 2;
                break;
            case 2:
                this.currentStep = 3;
                break;
            default:
                break;
        }

        console.log('>>>this.currentStep: ' + this.currentStep);
    }

The eventhandler-method is called correctly (I see it in the console), but and that's is the part I don't understand: The current-step of progress indicator is not changed visually.

Anyone an idea for the reason?

I am grateful for any help.


Best regards,
Chris
Hello everyone,

i try to build a custom lightning web component for a generic way to merge custom and standardobjects like the standard merge functionality for account, contact and leads.

Therefore i built two lwcs:
  • potentialDuplicates
  • mergeDuplicates
potentialDupplicates show the result for the duplicate rules (DuplicateRule), duplicate recordset (DuplicateRecordSet) and duplicate record item (DuplicateRecordItem) and looks like the following one:
https://ibb.co/gwp1fRk (https://ibb.co/jMRKJZL)

The first lwc (german language) show the salesforce standard "potential duplicates" component.
Below that - the highlighted one is my custom lwc.

The first screen (step1) looks like the following (Unfortunately I can't upload images - sorry for that):
https://ibb.co/MkJmmZT

After the selection and click on "Next" second screen (step2) appears and looks like the follwing:
https://ibb.co/xXQZDV1

On screen2 you have to choose the masterrecord and fields which has to move to masterrecord.

For comparison: In the standard potential duplicates the screen for step2 looks like the following:
https://ibb.co/5x7hfFv

I want to do this the exact same way. Here comes my problem: I didn't find a structure provided by apexcontroller that is able to iterate in a way to this list that columns and rows are syncron. The prepared structure of (selected) data records should be combined in such a way that they can be passed on to an apex controller, which then takes over the merge process.

One of my various solutions provide the following structure: Map<Id, List<Map<String, String>>>. Where key of map is the record id. The value of the outer map is a list with a map (key: apiname, value: fieldvalue). But this structure does not fit to the columns of screen2 and you can't iterate over map. Also a template expression doesn't allow NumericLiteral to access a specific index or key. It seems like everything has to be a list.

If I can realize this list of the selection, the processing of the data sets in Apex is only a child's play. Today I have worried all day about it and have not found an adequate solution.

Any suggestions for a provided structure of objects, arrays, maps to rule this target?

After i finished that components and everything works fine I am willing to publish the corresponding components.
Hi all,

in the documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation) a way is documented to preselect rows programmatically.
For this reason you should use "selected-rows"-attribut on lightning-datatable.

DOCUMENTATION

The selected-rows attribute enables programmatic selection of rows, which is useful when you want to preselect rows.
<lightning-datatable
    columns={columns}
    data={data}
    key-field="id"
    selected-rows={selectedRows}>
</lightning-datatable>
<lightning-button
    label="Select"
    onclick={handleSelect}>
</lightning-button>

To select a row programmatically, pass in the row key-field value.
// Load data via init handler first
// then handle programmatic selection
handleSelect() {
   const rows = ['a'];
   this.selectedRows = rows;
}

My component looks (simplfied) the following way:
export default class MergeDuplicates extends LightningElement {
    @track preSelectedRows = ['0011x00000KOMiJAAX'];
    
    [...]
}

My html-file (simplified) looks the following way:
<lightning-datatable
       key-field="Id"
       data={data}
       columns={columns}
       onrowselection={handleSelected}
       selected-rows={preSelectedRows}
       is-loading={tableLoadingState}>
</lightning-datatable>

My purpose: Preselect the current account, because the lwc is placed on a lightning record page for account.

My problem: Nothing happens. No checkbox is active.

One of my first ideas was the key-field. I changed it from "id" (lowercase) to "Id" (uppercase) but that don't solve the problem.

I don't know any other simpler way to test the preselect of rows for datatable than my example above.

Any suggestions?
Hi my friends,

currently I'm struggeling with the "current-step"-parameter on the lightning progress indictator (lightning-progress-indicator) in lightning web components.

I have a progress indicator:
<lightning-progress-indicator class="slds-align_absolute-center" current-step={currentStep} type="base" variant="base">
                                        <lightning-progress-step label="VIEW DUPLICATES" value=1></lightning-progress-step>
                                        <lightning-progress-step label="COMPARE RECORDS" value=2></lightning-progress-step>
                                        <lightning-progress-step label="CONFIRM MERGING" value=3></lightning-progress-step>
                                    </lightning-progress-indicator>

and a button that should switch the current step:
<lightning-button variant="brand" label="Next" title="Next" disabled={nextButtonDisabled} onclick={handleNext}></lightning-button>
and a corresponding eventhandler-method:
handleNext(){
        console.log('>>>handleNext in mergeDuplicates.js called.');
        console.log('>>>this.currentStep: ' + this.currentStep);

        switch (this.currentStep) {
            case 1:
                this.currentStep = 2;
                break;
            case 2:
                this.currentStep = 3;
                break;
            default:
                break;
        }

        console.log('>>>this.currentStep: ' + this.currentStep);
    }

The eventhandler-method is called correctly (I see it in the console), but and that's is the part I don't understand: The current-step of progress indicator is not changed visually.

Anyone an idea for the reason?

I am grateful for any help.


Best regards,
Chris