• Frank van Meegen 42
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies
On my community I have a page with a flow component that shows a screen flow with form fields.

For one of the fields need to be prefilled with a string via the URL. This field is populated via a variable in the flow called ReferralCode.

Passing a value in the variable via the internal url works fine. When I try to do the same for the community URL it does not pass the value of the url.

I tried the following url:
https://test-shbl.cs101.force.com/shbl/s/registration?ReferralCode=XYZ1

Is this even possible and if yes how can I achieve this?
In a lightning component I have a button that updates a field show__c on a child record. After the update the button should be invisible. This is only working after I do a page refresh.

How can I refresh the lightning component after the button click?
 
<aura:component controller="SampleController" Implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" >
    
    <aura:attribute name="childitems" type="List" />
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <!-- Use a data table from the Lightning Design System: https://www.lightningdesignsystem.com/components/data-tables/ -->
    
<table class="slds-table slds-table_bordered slds-table_cell-buffer slds-no-row-hover">
        <thead>
            <tr class="slds-text-heading_label">
                <th scope="col"><div class="slds-truncate" title="Button">Button</div></th>
                
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.childitems}" var="childitem">
                <tr>
   
                    <td>
                    <div class="slds-form-element">
                        <aura:renderIf isTrue="{!childitem.show__c}">
                        <lightning:button variant="brand" label="Sell" title="{!childitem.Id}" name="{!childitem.Id}" onclick="{!c.updateCheck11}" />
                 
                            </aura:renderIf>
                        </div>
                        
                    
                    </td>
                    
                    
                </tr>
            </aura:iteration>
        </tbody>
    </table>
 
</aura:component>

 
Hi,

I'm a bit stuck with a toggle checkbox in a lighting component datatable that should reflect a checkbox on the sobject (Contact.Active__c) in the datatable and update the specific checkbox when changed.

The datatable is a list of contacts related to the account that is opened in the screen. I would like to achieve the following scenarios:
  1. When the datatable is loaded the Toggle checkboxes in the SWITCH pane should reflect the true or false checkbox in the ACTIVE pane
  2. When the toggle checkbox is switched this should update the ACTIVE checkbox on the contact record to reflect the switched toggle checkbox
I cannot find a good example how to achieve this. Unfortunately the documentation regarding the ui:inputCheckbox is limited. I hope someone can help me with examples.

User-added image

APEX Controller
public class AccountsController1 {
    @AuraEnabled
    public static List <Contact> getAccounts(String aid) {
        system.debug('aid: ' +aid);
        List <Contact> Contacts = [SELECT Id, name,Email,Phone,Active__c  FROM Contact where AccountId=:aid ORDER BY createdDate ASC];
        System.debug('Contacts: ' +Contacts);
        return Contacts;
    }
}
Lightning component
<aura:component controller="AccountsController1" Implements="flexipage:availableForRecordHome,force:hasRecordId" >
    
    <aura:attribute name="contacts" type="List" />
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <!-- Use a data table from the Lightning Design System: https://www.lightningdesignsystem.com/components/data-tables/ -->
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">
                <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
                <th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
                <th scope="col"><div class="slds-truncate" title="Email">Email</div></th>
                <th scope="col"><div class="slds-truncate" title="Phone">Phone</div></th>
                <th scope="col"><div class="slds-truncate" title="Active__c">Active</div></th>
                <th scope="col"><div class="slds-truncate" title="Switch">Switch</div></th>
                
            </tr>
        </thead>
        <tbody>
            <!-- Use the Apex model and controller to fetch server side data -->
            <aura:iteration items="{!v.contacts}" var="contact">
                <tr>
                    <th scope="row"><div class="slds-truncate" title="{!contact.Id}">{!contact.Id}</div></th>
                    <td><div class="slds-truncate" title="{!contact.Name}">{!contact.Name}</div></td>
                    <td><div class="slds-truncate" title="{!contact.Email}">{!contact.Email}</div></td>
                    <td><div class="slds-truncate" title="{!contact.Phone}">{!contact.Phone}</div></td>
                    <td><div class="slds-truncate" title="{!contact.Active__c}">{!contact.Active__c}</div></td>
                    <td>
                        <div class="slds-m-around--large">
                            <!--PART 1 for create toggle switch/checkbox form element-->    
                            <div class="slds-form-element">
                                <label class="slds-checkbox_toggle slds-grid">
                                    <span class="slds-form-element__label slds-m-bottom_none"></span>
                                    <ui:inputCheckbox change="{!c.selectChange}"/>
                                    
                                    <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
                                        <span class="slds-checkbox_faux"></span>
                                        <span class="slds-checkbox_on">Active</span>
                                        <span class="slds-checkbox_off">Inactive</span>
                                    </span>
                                    
                                </label>
                            </div>
                            
                        </div>
                        
                    </td>
                    
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>

Lightning Component Controller
({
      doInit: function(component, event, helper) {
        // Fetch the account list from the Apex controller
        helper.getContactList(component);
      }
})
Lightning Component Helper
({
// Fetch the accounts from the Apex controller
      getContactList: function(component) {
        var action = component.get('c.getAccounts');
        action.setParams({
            "aid": component.get("v.recordId")
        });
        // Set up the callback
        var self = this;
        action.setCallback(this, function(actionResult) {
         component.set('v.contacts', actionResult.getReturnValue());
        });
        $A.enqueueAction(action);
      }
})


 
For a signature in an API connection I need to encode a string to SHA256 without using a key. Which method in APEX can I use for this?

String S = 'THIS IS AN EXAMPLE STRING';

If I encrupt this string to SHA256 via the following website I get a correct 64 character string without the use of a key:
http://md5decrypt.net/en/Sha256/#answer

Result = '2b970a5104771ac1890d755254e5ce9d2cc8e8d488961f241879e337fb8be502'

I cannot find a method in APEX that does the same.

The one that comes close is crypto.generateMac(algorithmName, input, privateKey) but this requires a key and Crypto.generateDigest(algorithmName, input) does not give a result that can be handled properly.
For a lightning community I would like to have unauthenticated users be directed to the standard login page when a button to an object page is pressed that require login. The behaviour now is that the user gets the standard error page.

Ideally after loging the user is forwarded to the specific page.
Hi all,

I'm trying to reproduce a javascript example for encryption in APEX. The javascript example looks like:
 
function makeSignature(nonce, data, command_url)
{
	const hashstring = nonce + data;
	const hashed = CryptoJS.SHA256(hashstring).toString(CryptoJS.enc.Latin1);
 	const encoded = CryptoJS.enc.Latin1.parse(command_url.concat(hashed));

 	return CryptoJS.HmacSHA512(encoded, API_SECRET).toString(CryptoJS.enc.Base64);
}
nonce = must always be an incremental value to prevent duplicates. Please use an unsigned 64 bit integer. To generate nonce values it is recommended to use time-related functions or other sequences.
data = 'username=' + convertUsername(API_USER) + '&nonce='+nonce;
command_url = '/v1/transaction/getBalance';

The code I have reproduced based on the example is as follows. Unfortunately this gives me an error "SIGNATURE_CHECK_FAILED" so I must be taking a wrong step.
public static String makeSignature(String nonce, String data, String command_url, String SecretKey){
        
        String hashstring = nonce + data;        
        
        String algorithmName256 = 'HmacSHA256';
        Blob HmacSHA256 = Crypto.generateMac(algorithmName256, Blob.valueOf(hashstring),Blob.valueOf(command_url));
        system.debug('HmacSHA256: ' + HmacSHA256);
        
        String algorithmName512 = 'HmacSHA512';
        Blob HmacSHA512 = Crypto.generateMac(algorithmName512, HmacSHA256,Blob.valueOf(SecretKey));
        
        system.debug('HmacSHA512: ' + HmacSHA512);
        
        return EncodingUtil.convertToHex(HmacSHA512);
Can someone please help me with the right steps?
 
For my community I have setup a custom domain with a signed certificate (.crt)

The Certificate Authority also provided a CA-Bundle file that I should also upload to Salesforce to solve the following issue:

 Chain Issues:close The chain doesn't contain any intermediate certificates

How should I upload this bundle to Salesforce? I cannot find an option for this.
I'm looking for a way to populate a lookup field based on a similar text value on the source and target object.

I have an object child__c with a lookup to parent__c and a field color__c. The field color__c is also available on the parent__c object with unique values.

How can I query the child__c records and populate the lookup with the parent__c record with the same color in color__c in APEX?
Hi,

I'm a bit stuck with a toggle checkbox in a lighting component datatable that should reflect a checkbox on the sobject (Contact.Active__c) in the datatable and update the specific checkbox when changed.

The datatable is a list of contacts related to the account that is opened in the screen. I would like to achieve the following scenarios:
  1. When the datatable is loaded the Toggle checkboxes in the SWITCH pane should reflect the true or false checkbox in the ACTIVE pane
  2. When the toggle checkbox is switched this should update the ACTIVE checkbox on the contact record to reflect the switched toggle checkbox
I cannot find a good example how to achieve this. Unfortunately the documentation regarding the ui:inputCheckbox is limited. I hope someone can help me with examples.

User-added image

APEX Controller
public class AccountsController1 {
    @AuraEnabled
    public static List <Contact> getAccounts(String aid) {
        system.debug('aid: ' +aid);
        List <Contact> Contacts = [SELECT Id, name,Email,Phone,Active__c  FROM Contact where AccountId=:aid ORDER BY createdDate ASC];
        System.debug('Contacts: ' +Contacts);
        return Contacts;
    }
}
Lightning component
<aura:component controller="AccountsController1" Implements="flexipage:availableForRecordHome,force:hasRecordId" >
    
    <aura:attribute name="contacts" type="List" />
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <!-- Use a data table from the Lightning Design System: https://www.lightningdesignsystem.com/components/data-tables/ -->
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">
                <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
                <th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
                <th scope="col"><div class="slds-truncate" title="Email">Email</div></th>
                <th scope="col"><div class="slds-truncate" title="Phone">Phone</div></th>
                <th scope="col"><div class="slds-truncate" title="Active__c">Active</div></th>
                <th scope="col"><div class="slds-truncate" title="Switch">Switch</div></th>
                
            </tr>
        </thead>
        <tbody>
            <!-- Use the Apex model and controller to fetch server side data -->
            <aura:iteration items="{!v.contacts}" var="contact">
                <tr>
                    <th scope="row"><div class="slds-truncate" title="{!contact.Id}">{!contact.Id}</div></th>
                    <td><div class="slds-truncate" title="{!contact.Name}">{!contact.Name}</div></td>
                    <td><div class="slds-truncate" title="{!contact.Email}">{!contact.Email}</div></td>
                    <td><div class="slds-truncate" title="{!contact.Phone}">{!contact.Phone}</div></td>
                    <td><div class="slds-truncate" title="{!contact.Active__c}">{!contact.Active__c}</div></td>
                    <td>
                        <div class="slds-m-around--large">
                            <!--PART 1 for create toggle switch/checkbox form element-->    
                            <div class="slds-form-element">
                                <label class="slds-checkbox_toggle slds-grid">
                                    <span class="slds-form-element__label slds-m-bottom_none"></span>
                                    <ui:inputCheckbox change="{!c.selectChange}"/>
                                    
                                    <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
                                        <span class="slds-checkbox_faux"></span>
                                        <span class="slds-checkbox_on">Active</span>
                                        <span class="slds-checkbox_off">Inactive</span>
                                    </span>
                                    
                                </label>
                            </div>
                            
                        </div>
                        
                    </td>
                    
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>

Lightning Component Controller
({
      doInit: function(component, event, helper) {
        // Fetch the account list from the Apex controller
        helper.getContactList(component);
      }
})
Lightning Component Helper
({
// Fetch the accounts from the Apex controller
      getContactList: function(component) {
        var action = component.get('c.getAccounts');
        action.setParams({
            "aid": component.get("v.recordId")
        });
        // Set up the callback
        var self = this;
        action.setCallback(this, function(actionResult) {
         component.set('v.contacts', actionResult.getReturnValue());
        });
        $A.enqueueAction(action);
      }
})


 
For a signature in an API connection I need to encode a string to SHA256 without using a key. Which method in APEX can I use for this?

String S = 'THIS IS AN EXAMPLE STRING';

If I encrupt this string to SHA256 via the following website I get a correct 64 character string without the use of a key:
http://md5decrypt.net/en/Sha256/#answer

Result = '2b970a5104771ac1890d755254e5ce9d2cc8e8d488961f241879e337fb8be502'

I cannot find a method in APEX that does the same.

The one that comes close is crypto.generateMac(algorithmName, input, privateKey) but this requires a key and Crypto.generateDigest(algorithmName, input) does not give a result that can be handled properly.
For my community I have setup a custom domain with a signed certificate (.crt)

The Certificate Authority also provided a CA-Bundle file that I should also upload to Salesforce to solve the following issue:

 Chain Issues:close The chain doesn't contain any intermediate certificates

How should I upload this bundle to Salesforce? I cannot find an option for this.
I'm looking for a way to populate a lookup field based on a similar text value on the source and target object.

I have an object child__c with a lookup to parent__c and a field color__c. The field color__c is also available on the parent__c object with unique values.

How can I query the child__c records and populate the lookup with the parent__c record with the same color in color__c in APEX?