• Andee Weir 17
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 11
    Replies
Hi,

I'm trying to display 2 columns of data in a LWC using <lightning-output-field>.  They are displaying ok (ideally I would want the labels not wrapping) but when I resize the browser window some of the columns jump too far to the right. 

Looking Ok :- Looking ok - ideally labels shouldn't be wrapping
Not so good when browser size made smaller :-
Preference Centre label aligning incorrectly
& things continue to move around if I reduce the browser size further :-
Last Client Approval moved
My html looking like :-
<template>
	<template if:true={readmode}>
		<div class="centerButtonDiv">
			<lightning-button variant="brand" label="Update Preferences" onclick={customShowModalPopup}>
			</lightning-button>
		</div>
		<lightning-record-view-form record-id={recordId} object-api-name={ObjectName}>
			
			<div class="slds-grid slds-gutters">
				<div class="slds-size_1-of-2">
					<lightning-output-field field-name="Preferences_Are_Client_Approved__c"></lightning-output-field><br/>
					<lightning-output-field field-name="Last_Client_Approval_Given_By__c"></lightning-output-field><br/>
					<lightning-output-field field-name="Preference_Centre_Visited__c"></lightning-output-field><br/>
				</div>

				<div class="slds-size_1-of-2">
					<lightning-output-field field-name="Date_of_Last_Client_Approval__c"></lightning-output-field><br/>
					<lightning-output-field field-name="HasOptedOutOfEmail"></lightning-output-field><br/>
					<lightning-output-field field-name="Do_not_email__c"></lightning-output-field><br/>
				</div>
			</div>
		</lightning-record-view-form>
	</template>
</template>
The related css file has no relevant code.

Thanks in advance for any help that can be offered. 
Hi,

We currently have a mapping of lead fields to account e.g. Street Line 1 etc.  We also have a process builder flow that kicks off a batch process if an account's address changes.  The final piece of the puzzle is a scheduled batch job that automatically converts leads into contacts if certain criteria are met. 

The problem is that when this scheduled batch job runs, the lead to contact apex code attaches an existing account to the new contact which seems to cause the account to be updated (I think this is vanilla salesforce because of the lead to account field mapping) which in turn causes the process builder flow to start (& fail) as it cannot start a batch job from a batch job.

So is it possible to recognise in the flow if the account update is due to lead conversion or alternatively if the flow is already running in a batch?  If not, is there a way to force the lead field mapping to only happen if a new account is being created & ignore updates to existing accounts.  The process builder update needs to run as a batch as it updates all of the account's contacts which could be many. 

Thanks in advance for any help you can offer.
 
Hi all,

I've read other postings about how to pass parameters from a visualforce page to a lightning component but cannot get it to work.  In my case I have created my own custom version of  a related list as a lightning component (All Financial Accounts in Third Party's Hierarchy) but want to add the functionality that if there are more than 6 items, the View All link at the bottom of the component opens up the same component in a new page with slightly different paramaters so that more columns & rows are shown (similar to normal related list functionality). 

Screenshot of custom component related list
I'm attempting to do this by navigating to a new visualforce page which uses lightning:isUrlAddressable but I get a 'Lightning out App error in callback function error' when it trys to display the lightning component.  This can be demonstrated in a cutdown version of the code :

LC1.cmp:
<aura:component implements='flexipage:availableForAllPageTypes, lightning:isUrlAddressable' access='global'> 
	<aura:attribute name="param1" type="String" default="AAA"/>    
    
    <p>{!v.param1}</p>
    <a href="javascript:void(0);" onclick="{!c.changeParam}">Change Parameter</a>    
    
</aura:component>

LC1Controller.js :
({
	changeParam : function(component, event, helper) {
		var urlEvent = $A.get("e.force:navigateToURL"); 
        urlEvent.setParams({ "url":"/apex/VfPage?param1=BBB" }); 
        urlEvent.fire();
	}
})
VfPage.vfp :
<apex:page >
    <apex:includeLightning />
    <script>
    $Lightning.use("c:LC1Container", function() {
            $Lightning.createComponent("c:LC1",
                                       {
                                           "param1" : "BBB" // Removing this still has the same error
                                       },
                                       "lightning",
                                       function(cmp) {
                                           console.log('Component created');
                                       });
        });
    </script>
    
    {!$CurrentPage.parameters.param1}
</apex:page>

LC1Container.app :
<aura:application access="GLOBAL" extends="ltng:outApp" >
    <aura:dependency resource="c:LC1"/>
</aura:application>
I then added LC1 to the top of the Account's Lightning Page | Related List tab.  The end result looks like :
Change param 1

When I click on Change Parameter I get :
Change param 2

​​​​​​​Any suggestions on how get this component to load successfully with the new value of the parameter?
​​​​​​​
Thanks for any help that can be offered.
Very new to Flow so not sure if what I'm trying to achieve is possible or not.

In essense I want a flow to call a custom Lightning Component which returns an array of contacts which the flow should store in a variable for later processing.  I've defined the LC which at the moment just returns the last 10 created contacts (the real LC will allow user input & be more complex but I've stripped it right back for the moment) :-

Apex Controller :-
public with Sharing class TestReturnContactscontroller {
	@AuraEnabled
    public static list<Contact> getContacts() 
    {
        list<contact> contacts = [select id, name from contact order by createdDate desc limit 10];
        
        return contacts;
    }
}

 LC :-
<aura:component controller="TestReturnContactscontroller" implements="force:appHostable,force:lightningQuickAction,lightning:availableForFlowScreens" access="global">
	
    <aura:attribute name="contacts" type="contact[]" description="Array of contacts returned"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

LC Controller :-
({
	doInit : function(component, event, helper) {
		var action = component.get('c.getContacts');
                           
        // Define the callback
        action.setCallback(this, function(response) {
            var state = response.getState();
            
            if (component.isValid() && state === "SUCCESS")
            {
                // Callback succeeded
            	console.log('Successful response from doInit ---> ',response.getReturnValue());
                
                // Get the label of the object
                var result = response.getReturnValue();
                
                component.set('v.contacts', result);
                
            }
        });
        
        // Enqueue the action                  
        $A.enqueueAction(action); 
	}
})

LC Design :-
<design:component>
	<design:attribute name="contacts" label="contacts : return list" />
</design:component>
When I put this into a Flow I can see the console.log statement & an array of 10 contact ids/names.  However I cannot work out how to get these results into a flow variable.  In my flow I've created a Screen which contains my LC but the the field for 'contacts' in the Store Output Values only seems to want a variable for a single contact not one that I've defined as a collection.  Is what I am trying to do possible & if so, what am I doing wrong?

Thanks in advance for any help.
Hi,

I was hoping someone might be able to explain why when my debug logging level in Developer Console is set to a fairly fine setting (i.e. ApexCode :Finer, Workflow:Finer, Visualforce:Finer, DB:Info, Wave:Info, Nba:Info, the remainder set to none), a test class is consistently failing (Limit exceeded :Too many SOQL queries) but when I only have DB:Info turned on the test class works.  Surely logging levels do not affect the Salesforce limits?
Hi.

I'm trying to user Live Agent's rest API to retrieve the current session id to then subsequently retrieve if any agents are online or not.  I can call the rest API using a Chrome extension called Restlet Client & see the correct response.  However when I try to make the same call using Javascript I get 'https://xxx.salesforceliveagent.com/chat/rest/System/SessionId 400 (Bad Request)' when performing the request.send().

The javascript being used, with the appropriate URLs being anonymised, is shown below.  The restApi function gets the error but the movies function, which is basically the same but to a public rest API service which requires no request headers, doesn't.  Any suggestions would be very gratefully received. 
 
<html>
    <head>
    </head>
    <body>

        <button type="submit" onclick="javascript:restApi()">RestApi</button>
        
        <button type="submit" onclick="javascript:movies()">Movies</button>
        
    
        <script type="text/javascript">
            
            function restApi(){
                var request = new XMLHttpRequest();

                request.open('GET', 'https://xxx.salesforceliveagent.com/chat/rest/System/SessionId', true);
                request.setRequestHeader('X-LIVEAGENT-API-VERSION', '34');
                request.setRequestHeader('X-LIVEAGENT-AFFINITY', '');
                request.onload = function () {
                    var data = JSON.parse(this.response);
                    console.log(request.status);
                        if (request.status >= 200 && request.status < 400) {
                            console.log('worked');
                        } else {
                            console.log('error');
                        }
                }

                request.send();
            }
            
            function movies(){
                var request = new XMLHttpRequest();

                request.open('GET', 'https://ghibliapi.herokuapp.com/films', true);
                request.setRequestHeader('X-LIVEAGENT-API-VERSION', '34');
                request.setRequestHeader('X-LIVEAGENT-AFFINITY', '');
                request.onload = function () {
                    var data = JSON.parse(this.response);
                    console.log(request.status);
                        if (request.status >= 200 && request.status < 400) {
                            console.log('worked');
                            data.forEach(movie => {
                                console.log(movie.title);
                            });
                        } else {
                            console.log('error');
                        }
                }

                request.send();
            }

            
        </script>

    </body>
<html> 
Hi & thanks for taking the time to look at my question,

I have a requirement to only allow system admins to uncheck a checkbox on a custom lightning component.  I've included example code below that replicates some of the behaviour but jI cannot work out how to set the value of the checkbox back to true if the alert is displayed.  Hopefully it's pretty obvious what I am trying to do from the code.  Just for your information the real component has the inputcheckbox inside a <aura:iteration/> so I don't think I can use anything like Document.getElementById().

Thanks again.

Component :-

<aura:component >
    <ui:inputCheckbox aura:id="childCheckbox" value="true" change="{!c.onChangeChildCheckbox}"/>Test
</aura:component>

Controller :-
({

    onChangeChildCheckbox : function(component, event, helper) {

        // If the checkbox was unchecked by the user...
        if(!event.getSource().get('v.value')){
            var profileName = "Basic User"; // This would normally be coming from the component class

            // If the user is not a system administrator, display alert & set the checkbox back to checked 
            if (profileName != "System Administrator"){
                alert("Not Allowed!");
                // PROBLEM - How to set the checkbox value to be checked. Code below doesn't work
                var temp = event.getSource();
                temp.value = true;
            }
        }
    }
})
Hi,

I'm trying to display 2 columns of data in a LWC using <lightning-output-field>.  They are displaying ok (ideally I would want the labels not wrapping) but when I resize the browser window some of the columns jump too far to the right. 

Looking Ok :- Looking ok - ideally labels shouldn't be wrapping
Not so good when browser size made smaller :-
Preference Centre label aligning incorrectly
& things continue to move around if I reduce the browser size further :-
Last Client Approval moved
My html looking like :-
<template>
	<template if:true={readmode}>
		<div class="centerButtonDiv">
			<lightning-button variant="brand" label="Update Preferences" onclick={customShowModalPopup}>
			</lightning-button>
		</div>
		<lightning-record-view-form record-id={recordId} object-api-name={ObjectName}>
			
			<div class="slds-grid slds-gutters">
				<div class="slds-size_1-of-2">
					<lightning-output-field field-name="Preferences_Are_Client_Approved__c"></lightning-output-field><br/>
					<lightning-output-field field-name="Last_Client_Approval_Given_By__c"></lightning-output-field><br/>
					<lightning-output-field field-name="Preference_Centre_Visited__c"></lightning-output-field><br/>
				</div>

				<div class="slds-size_1-of-2">
					<lightning-output-field field-name="Date_of_Last_Client_Approval__c"></lightning-output-field><br/>
					<lightning-output-field field-name="HasOptedOutOfEmail"></lightning-output-field><br/>
					<lightning-output-field field-name="Do_not_email__c"></lightning-output-field><br/>
				</div>
			</div>
		</lightning-record-view-form>
	</template>
</template>
The related css file has no relevant code.

Thanks in advance for any help that can be offered. 
Hi all,

I've read other postings about how to pass parameters from a visualforce page to a lightning component but cannot get it to work.  In my case I have created my own custom version of  a related list as a lightning component (All Financial Accounts in Third Party's Hierarchy) but want to add the functionality that if there are more than 6 items, the View All link at the bottom of the component opens up the same component in a new page with slightly different paramaters so that more columns & rows are shown (similar to normal related list functionality). 

Screenshot of custom component related list
I'm attempting to do this by navigating to a new visualforce page which uses lightning:isUrlAddressable but I get a 'Lightning out App error in callback function error' when it trys to display the lightning component.  This can be demonstrated in a cutdown version of the code :

LC1.cmp:
<aura:component implements='flexipage:availableForAllPageTypes, lightning:isUrlAddressable' access='global'> 
	<aura:attribute name="param1" type="String" default="AAA"/>    
    
    <p>{!v.param1}</p>
    <a href="javascript:void(0);" onclick="{!c.changeParam}">Change Parameter</a>    
    
</aura:component>

LC1Controller.js :
({
	changeParam : function(component, event, helper) {
		var urlEvent = $A.get("e.force:navigateToURL"); 
        urlEvent.setParams({ "url":"/apex/VfPage?param1=BBB" }); 
        urlEvent.fire();
	}
})
VfPage.vfp :
<apex:page >
    <apex:includeLightning />
    <script>
    $Lightning.use("c:LC1Container", function() {
            $Lightning.createComponent("c:LC1",
                                       {
                                           "param1" : "BBB" // Removing this still has the same error
                                       },
                                       "lightning",
                                       function(cmp) {
                                           console.log('Component created');
                                       });
        });
    </script>
    
    {!$CurrentPage.parameters.param1}
</apex:page>

LC1Container.app :
<aura:application access="GLOBAL" extends="ltng:outApp" >
    <aura:dependency resource="c:LC1"/>
</aura:application>
I then added LC1 to the top of the Account's Lightning Page | Related List tab.  The end result looks like :
Change param 1

When I click on Change Parameter I get :
Change param 2

​​​​​​​Any suggestions on how get this component to load successfully with the new value of the parameter?
​​​​​​​
Thanks for any help that can be offered.
Very new to Flow so not sure if what I'm trying to achieve is possible or not.

In essense I want a flow to call a custom Lightning Component which returns an array of contacts which the flow should store in a variable for later processing.  I've defined the LC which at the moment just returns the last 10 created contacts (the real LC will allow user input & be more complex but I've stripped it right back for the moment) :-

Apex Controller :-
public with Sharing class TestReturnContactscontroller {
	@AuraEnabled
    public static list<Contact> getContacts() 
    {
        list<contact> contacts = [select id, name from contact order by createdDate desc limit 10];
        
        return contacts;
    }
}

 LC :-
<aura:component controller="TestReturnContactscontroller" implements="force:appHostable,force:lightningQuickAction,lightning:availableForFlowScreens" access="global">
	
    <aura:attribute name="contacts" type="contact[]" description="Array of contacts returned"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

LC Controller :-
({
	doInit : function(component, event, helper) {
		var action = component.get('c.getContacts');
                           
        // Define the callback
        action.setCallback(this, function(response) {
            var state = response.getState();
            
            if (component.isValid() && state === "SUCCESS")
            {
                // Callback succeeded
            	console.log('Successful response from doInit ---> ',response.getReturnValue());
                
                // Get the label of the object
                var result = response.getReturnValue();
                
                component.set('v.contacts', result);
                
            }
        });
        
        // Enqueue the action                  
        $A.enqueueAction(action); 
	}
})

LC Design :-
<design:component>
	<design:attribute name="contacts" label="contacts : return list" />
</design:component>
When I put this into a Flow I can see the console.log statement & an array of 10 contact ids/names.  However I cannot work out how to get these results into a flow variable.  In my flow I've created a Screen which contains my LC but the the field for 'contacts' in the Store Output Values only seems to want a variable for a single contact not one that I've defined as a collection.  Is what I am trying to do possible & if so, what am I doing wrong?

Thanks in advance for any help.
Hi & thanks for taking the time to look at my question,

I have a requirement to only allow system admins to uncheck a checkbox on a custom lightning component.  I've included example code below that replicates some of the behaviour but jI cannot work out how to set the value of the checkbox back to true if the alert is displayed.  Hopefully it's pretty obvious what I am trying to do from the code.  Just for your information the real component has the inputcheckbox inside a <aura:iteration/> so I don't think I can use anything like Document.getElementById().

Thanks again.

Component :-

<aura:component >
    <ui:inputCheckbox aura:id="childCheckbox" value="true" change="{!c.onChangeChildCheckbox}"/>Test
</aura:component>

Controller :-
({

    onChangeChildCheckbox : function(component, event, helper) {

        // If the checkbox was unchecked by the user...
        if(!event.getSource().get('v.value')){
            var profileName = "Basic User"; // This would normally be coming from the component class

            // If the user is not a system administrator, display alert & set the checkbox back to checked 
            if (profileName != "System Administrator"){
                alert("Not Allowed!");
                // PROBLEM - How to set the checkbox value to be checked. Code below doesn't work
                var temp = event.getSource();
                temp.value = true;
            }
        }
    }
})
I am testing OAuth integration with my App. Everything was going fine until over the weekend I lost my refresh tokens for my test accounts.

Now I am receiving this error:
{"error":"invalid_grant","error_description":"expired authorization code"}

The redirect back returns a code. This code never changes. However, this code is deemed expired once I try to request an access token and refresh token. I imagine this is because the initial access token has expired and I need to use the refresh token to gain a new one. However, I do not have access to the original refresh tokens.

My question is, how to I reset this whole thing? I have tried the following in all possible combinations:

- In the client login, revoked oauth access to all apps
- In the client login, Reset API Key
- In the developer login, modify redirect_uri
- In the developer login, completely delete exisiting app and create a new one. The new app gives the same error.

I would just like to get both the Client Login and Developer Login App reset to square one. Then I can request my access and refresh tokens and, this time, reliably store them.
In my test class I insert new products and pricebookentries, in my test class I don't use seeAllDate=true annotation and in order to retrieve standard pricebook id I used Test.getStandardPricebookId() method, here's my code:
Product2 p1 = new Product2(Name='Product Monthly 1111', Family='Monthly', isActive=true, CurrencyIsoCode='USD');
Product2 p2 = new Product2(Name='Product Yearly 2222', Family='Yearly', isActive=true, CurrencyIsoCode='USD');

insert new List<Product2>{p1, p2};

Id pricebookId = Test.getStandardPricebookId();

PricebookEntry pbe1 = new PricebookEntry(Pricebook2id=pricebookId, Product2id=p1.ID, isActive=true, CurrencyIsoCode='USD', unitPrice=100);
PricebookEntry pbe2 = new PricebookEntry(Pricebook2id=pricebookId, Product2id=p2.ID, isActive=true, CurrencyIsoCode='USD', unitPrice=50);

insert pbe1;
insert pbe2;

List<PricebookEntry> pbes = [SELECT ID FROM PricebookEntry 
    WHERE Product2id IN (:p1.Id, :p2.Id) AND Pricebook2.isStandard = TRUE AND Pricebook2.isActive = TRUE AND CurrencyIsoCode = 'USD' AND isActive = TRUE];

System.assertEquals(2, pbes.size());


pbes.size() returns 0. I used the same query in console for existing data and I got results. What am I doing wrong?

Which kind of object is MyUnresolved Items?. I have a custom object called Candidates__c which has Main_Email__c as one of the fields, the problem is that when a Salesforce user(User with an account in salesforce) receives an email from a Candidate and the Salesforce user autoforwards the Email to salesforce using the Email to Salesforce generated url, the email is saved under the Unresolved Items, Is it possible to automatically assign the email to the specific custom object 'Candidates__c', lets say using a trigger which gets fired on 'after insert'. Anyone with an idea on how to go about this?!!