• MasahiroY
  • NEWBIE
  • 45 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 11
    Replies
Hi all, I'm in trouble with screen flow.
Labels are shown.
User-added image

Labels disappeared...
User-added image
The labels disappear despite they are shown on the flow designer's screen. I appreciate it if anyone knows the reason why or encountered the same bugs and how to solve this? 
Thanks!


 
Hi all, I'm working on the InvocableMethod with Flow.  What it's supposed to deliver is put List<Id> in the apex action then return unique List<Id>. Here's the code.
public class lookUpAccountAnnotation {
   @InvocableMethod
    public static List<outputParam> getAccountIds(List<inputParam> param) {
        Set<Id> uniqueIds = new Set<Id>();
        uniqueIds.addall(param[0].inputIds);

        outputParam response = new outputParam();
        response.outputIds.addAll(uniqueIds);
        
        List<outputParam> outputs = new List<outputParam>();
        outputs.add(response);
        
        return outputs;
    }

    public class inputParam {
        @InvocableVariable(required=false label='AccountIDs for input')
        public List<Id> inputIds;
    }
    
    public class outputParam {
        @InvocableVariable(required=false label='AccountIDs for output')
        public List<Id> outputIds;
    }
}
With system.debug() in each variable, you can get the Ids for param and uniqueIds, but it seems it stopped by response before reaching system.debug (response)

Do you have any solution for this? It's pretty much generic wherever you can use inputting Ids and returning unique output Ids if this code works.

Thanks!

 
I'm working on "Rollup Summary in Lookup relation". It seems after-update and after-delete work fine, it rolls up child object fields to and updates fields in parent object safely.
Parent = Edition__c
Child   = Booking__c

But after-insert or creating new records triggers the NullPointerException and CAN NOT INSERT UPDATE ACTIVATE ENTITY.

"Error Occurred: The flow tried to update these records: null.
This error occurred: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Booking2EditionTrigger: execution of AfterUpdate caused by: System.NullPointerException: Argument cannot be null. Trigger.Booking2EditionTrigger: line 38, column 1."
 
Trigger
https://gist.github.com/liuxiachanghong/7ac277f158f64ec54a3f4c3543a15832

Thanks for your advice!
I'm working on Apex, and enconuter a problem how to check the blank value in integer varibale. Here're the codes.

Pass the number input from lightning:input to Apex Class.
component
<aura:attribute name="searchValue" type="Integer"/> 
                <div class="flex-item space-digit text-overflow-hide">
                <lightning:input
                    type="number"
                    name="Limit"
                    label="Value"
                    value="{!v.searchValue}"
                    onchange="{!c.onSearchTermChange}"
                />
                </div>


 
Switch the condition query in Dynamic SOQL, if !=null, then skip this WHERE clause.
 
Apex
if (searchValue!=null){
        searchQuery += ' AND Billing_Total__c=:searchValue ';
 }


 
However, this returns that default value of searchValue is null
If you entrer any value, it determined as !=null
If you erase the value and it's determied !=null but no value (blank?)

Do you know how to check if the Interger is blank?
I tried these but they didn't work.
if (searchValue!=null || String.isNotEmpty(String.valueOf(searchValue)))
if (searchValue!=null || String.isNotBlank(String.valueOf(searchValue)))
Thanks for your advice!

I have made a Lightning Component that lists all the nearby accounts based on the geo location of the specific account record. I added to list Leads as well by the same Class but the different method, but it only shows the Accounts, but not the Leads.

1. The component passes the recordId to the controller
2. the controller gets the accounts and lead back from Class
3. The controller returns the list of leads and accounts
4. The component shows the result of the list

I suppose the reason is the cmp.set(v.rows,rows); in the Controller seems overwriting previous values set. If anyone knows the best solution for this?

Class
public class MapNearbyLeadController {
	@AuraEnabled
    public static List<Account> getAccounts(String recordId){
		Lead lead = [SELECT Id,Latitude,Longitude,Industry,Sub__c FROM Lead WHERE Id = :recordId];        
        return [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet, BillingLatitude, BillingLongitude,Industry, Description, Related_Opportunities_y__c,Recent_Closed_Won_Date__c,Owner_Alias__c,Sub__c,Client_Type_new__c,Distance__c
                FROM Account 
                WHERE DISTANCE(BillingAddress, GEOLOCATION(:lead.Latitude,:lead.Longitude), 'km') < 6 AND Industry = :lead.Industry AND Sub__c = :lead.Sub__c ORDER BY Related_Opportunities_y__c DESC, DISTANCE(BillingAddress, GEOLOCATION(:lead.Latitude,:lead.Longitude), 'km') ASC LIMIT 30];
    }
    
	public static List<Lead> getLeads(String recordId){
		List<Lead> leads = new List<Lead>();
        leads = [SELECT Id,State,City,Street,Latitude,Longitude,Industry,Sub__c FROM Lead WHERE Id = :recordId LIMIT 1];
        return leads;        
    }
}

Component
<aura:component controller="MapNearbyLeadController" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    <lightning:navigation aura:id="navigation"/>
    <aura:attribute name="mapMarkers" type="Object"/>
    <aura:attribute name="rows" type="Map[]"/>
    <aura:attribute name="cols" type="Map[]"/>
    
    <aura:attribute name="selectedMarkerValue" type="String" />
    
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>   
    <div class="slds-box">
       <lightning:card title="Accounts Nearby" iconName="standard:account">
        <lightning:datatable
            data="{!v.rows}"
            columns="{!v.cols}"
            minColumnWidth="80px"
            wrapTextMaxLines ="2"
            sortable = "true"              
            keyField="Id"
            hideCheckboxColumn="true"
            showRowNumberColumn="true" />
    </lightning:card>
        </div>
</aura:component>
Controller
({
    init: function (cmp, event, helper) {     
        var cols = [
            {
                label: 'Name',
                fieldName: 'linkName',
                type: 'url',
                fixedWidth: 200,
                typeAttributes: {
                    label: {fieldName:'Name'},
                    target : '_blank'
                }
            },
            {
                label: 'Deal',
                fieldName: 'Related_Opportunities_y__c',
                fixedWidth: 80,
                type: 'number'
            },
            {
                label: 'Won Date',
                fieldName: 'Recent_Closed_Won_Date__c',
                fixedWidth: 120,
                type: 'date'
            },
            {
                label: 'Owner',
                fieldName: 'Owner_Alias__c',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'Client Type',
                fieldName: 'Client_Type_new__c',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'Industry',
                fieldName: 'Industry',
                fixedWidth: 100,
                type: 'text'
            },
            {
                label: 'State',
                fieldName: 'BillingState',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'City',
                fieldName: 'BillingCity',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'Street',
                fieldName: 'BillingStreet',
                fixedWidth: 200,
                type: 'text'
            }
        ];
        
        cmp.set( 'v.cols', cols );

        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getAccounts");
        action.setParams({recordId :recordId});           
        action.setCallback(this, function(response){
            
            var accounts = response.getReturnValue();
            var rows = [];
            for(var i = 0; i < accounts.length; i++){
                var acc = accounts[i];
                rows.push({
                    Id: acc.Id,
                    linkName: '/'+ acc.Id,
                    Name: acc.Name,
                    Industry: acc.Industry,
                    BillingState: acc.BillingState,
                    BillingCity: acc.BillingCity,
                    BillingStreet: acc.BillingStreet,
                    Related_Opportunities_y__c: acc.Related_Opportunities_y__c,
                    Recent_Closed_Won_Date__c: acc.Recent_Closed_Won_Date__c,
                    Owner_Alias__c: acc.Owner_Alias__c,
                    Client_Type_new__c:acc.Client_Type_new__c
                    });
            }
            
            if(rows.length != 0){
                cmp.set('v.rows', rows);
            }
        });     
/* 
  */     
        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getLeads");
        action.setParams({recordId :recordId}); 
        action.setCallback(this, function(response){
            
            var leads = response.getReturnValue();
            var rows = [];
            for(var i = 0; i < leads.length; i++){
                var ld = leads[i];
                rows.push({
                    Id: ld.Id,
                    linkName: '/'+ ld.Id,
                    Name: ld.LastName,
                    BillingIndustry: ld.Industry,
                    BillingState: ld.State,
                    BillingCity: ld.City,
                    BillingStreet: ld.Street,
                    Related_Opportunities_y__c: '',
                    Recent_Closed_Won_Date__c: '',
                    Owner_Alias__c: '',
                    Client_Type_new__c:''
                    });
            }
            
            if(rows.length != 0){
                cmp.set('v.rows', rows);
            }
        });
        
/*
*/  
        $A.enqueueAction(action);
    },

    handlerMarkerSelect: function (cmp, event, helper) {
        console.log(event.getParam("selectedMarkerValue"));
    }
});
Thanks in advance!

 
I've successfully plotted the accounts on Google Map with Lightning Component and it works in Sandbox...but don't know how to write a test code for the ApexClass.

I describe the codes below and hope anyone can help with the test code part. Thank you!

Component (MapNearbyAccount.cmp)
<aura:component controller="MapNearbyAccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    <aura:attribute name="mapMarkers" type="Object"/>
    <aura:attribute name="selectedMarkerValue" type="String" />
    
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    
    <div class="slds-box slds-theme--default">
        <lightning:map 
                       mapMarkers="{! v.mapMarkers }"
                       selectedMarkerValue="{!v.selectedMarkerValue}"
                       markersTitle="accounts nearby"
                       listView="auto"
                       showFooter="false"
                       onmarkerselect="{!c.handlerMarkerSelect}" />
    </div>
</aura:component>
Controller (MapNearbyAccount.js)
({
    init: function (cmp, event, helper) {
        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getAccounts");
        action.setParams({recordId :recordId});
        cmp.set('v.mapMarkers', [{location: {}}]);

        action.setCallback(this, function(response){
            
            var accounts = response.getReturnValue();
            var markers = [];
            for(var i = 0; i < accounts.length; i++){
                var acc = accounts[i];
                markers.push({
                    location: {
                        Country : acc.BillingCountry,
                        State : acc.BillingState,
                        City: acc.BillingCity,
                        Street: acc.BillingStreet
                    },
    
                    icon : "standard:account",
                    value: acc.Id,
                    title: acc.Name,
                    description:acc.Description
                });
            }
            
            if(markers.length != 0){
                cmp.set('v.mapMarkers', markers);
            }
        });

        $A.enqueueAction(action);
    },

    handlerMarkerSelect: function (cmp, event, helper) {
        console.log(event.getParam("selectedMarkerValue"));
    }
});
ApexClass (MapNearbyAccountController)
public class MapNearbyAccountController {
    @AuraEnabled
    public static List<Account> getAccounts(String BillingCity, String BillingState, String recordId){
        Account acct = [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet, Industry FROM Account WHERE Id =:recordId];
        
        return [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet,Description
                FROM Account 
                WHERE BillingState = :acct.BillingState AND BillingCity LIKE :('%' + acct.BillingCity + '%') AND Industry = :acct.Industry LIMIT 10];
    }
}
TestClass
@isTest
public class MapNearbyAccountControllerTest {
@isTest
    static void testMapNearbyAccountController() {
        Account acc1 = new Account();
        acc1.Name='acc1';
        acc1.BillingCity='Shibuya';
        acc1.BillingState='Tokyo';
        insert acc1;
        
        MapNearbyAccountController ctrl = new MapNearbyAccountController();
        
        Test.startTest();
            List<Account> getAccounts = ctrl.getAccounts();
            System.assertEquals(false,getAccounts.isEmpty());
        Test.stopTest();
    }
    
}
I am trying to pass the value of an inputfield as Contact lookup field (Opportunity.Contact__c) from my Visualforce page (standardController = Opportunity) to my controller. 

I still don't figure out how the controller can receive the value from that Lookup value and its ID. It seems the Lookup field the datatype seems sObject, but Contact email_recipient can't receive it.

Similar post here but it doesn't help me, since I use the InputField value preset from Opportunity.Contact__c (Contact Lookup filed)
https://developer.salesforce.com/forums/?id=906F0000000MMDoIAO

Thanks for help!

VF (snippet)
<apex:form >
<apex:inputText html-placeholder="Subject" id="email_subject" value="{!email_subject}" />
<apex:inputtextarea html-placeholder="Body" rows="15" id="email_body" value="{!email_body}" />
<apex:inputField html-placeholder="Billing Contact" id="email_recipient" value="{!Opportunity.Contact__c}" />
<!-- this inputField value is from Contact Lookup filed of the Opportunity. This might be the cause of issue?? -->
          
<apex:pageBlock id="actions"> 
    <apex:param name="email_subjectText" assignTo="{!email_subject}" value="Authorization PDF"/>
    <apex:param name="email_body" assignTo="{!email_body}" value="Authorization PDF"/>
    <apex:commandButton action="{!SendPdf}" value="Send PDF"/>
</apex:pageBlock> 
</apex:form>
Controller (snippet)
public with sharing class PdfGeneratorController {
	public String email_subject {get;set;}
    public String email_body {get;set;}
    public String cont_email {get;set;}
	public Contact email_recipient {get;set;}

// this block turns error Compile Error: Illegal assignment from Schema.SObjectField to Contact
    email_recipient = new Contact();
    email_recipient = Opportunity.Contact__c;  // this might be wrong?
    cont_email = email_recipient.Email;
//

    public PageReference SendPdf() { 
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(new String[] {cont_email});
            mail.setSubject(email_subject);
            mail.setPlainTextBody(email_body);
            mail.setWhatId(parentId);
            mail.setEntityAttachments(Ids);
            Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});       
    }
}
Actual VF page look like. (red text is what's in VF code)
User-added image

 
I've successfully plotted the accounts on Google Map with Lightning Component and it works in Sandbox...but don't know how to write a test code for the ApexClass.

I describe the codes below and hope anyone can help with the test code part. Thank you!

Component (MapNearbyAccount.cmp)
<aura:component controller="MapNearbyAccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    <aura:attribute name="mapMarkers" type="Object"/>
    <aura:attribute name="selectedMarkerValue" type="String" />
    
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    
    <div class="slds-box slds-theme--default">
        <lightning:map 
                       mapMarkers="{! v.mapMarkers }"
                       selectedMarkerValue="{!v.selectedMarkerValue}"
                       markersTitle="accounts nearby"
                       listView="auto"
                       showFooter="false"
                       onmarkerselect="{!c.handlerMarkerSelect}" />
    </div>
</aura:component>
Controller (MapNearbyAccount.js)
({
    init: function (cmp, event, helper) {
        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getAccounts");
        action.setParams({recordId :recordId});
        cmp.set('v.mapMarkers', [{location: {}}]);

        action.setCallback(this, function(response){
            
            var accounts = response.getReturnValue();
            var markers = [];
            for(var i = 0; i < accounts.length; i++){
                var acc = accounts[i];
                markers.push({
                    location: {
                        Country : acc.BillingCountry,
                        State : acc.BillingState,
                        City: acc.BillingCity,
                        Street: acc.BillingStreet
                    },
    
                    icon : "standard:account",
                    value: acc.Id,
                    title: acc.Name,
                    description:acc.Description
                });
            }
            
            if(markers.length != 0){
                cmp.set('v.mapMarkers', markers);
            }
        });

        $A.enqueueAction(action);
    },

    handlerMarkerSelect: function (cmp, event, helper) {
        console.log(event.getParam("selectedMarkerValue"));
    }
});
ApexClass (MapNearbyAccountController)
public class MapNearbyAccountController {
    @AuraEnabled
    public static List<Account> getAccounts(String BillingCity, String BillingState, String recordId){
        Account acct = [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet, Industry FROM Account WHERE Id =:recordId];
        
        return [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet,Description
                FROM Account 
                WHERE BillingState = :acct.BillingState AND BillingCity LIKE :('%' + acct.BillingCity + '%') AND Industry = :acct.Industry LIMIT 10];
    }
}
TestClass
@isTest
public class MapNearbyAccountControllerTest {
@isTest
    static void testMapNearbyAccountController() {
        Account acc1 = new Account();
        acc1.Name='acc1';
        acc1.BillingCity='Shibuya';
        acc1.BillingState='Tokyo';
        insert acc1;
        
        MapNearbyAccountController ctrl = new MapNearbyAccountController();
        
        Test.startTest();
            List<Account> getAccounts = ctrl.getAccounts();
            System.assertEquals(false,getAccounts.isEmpty());
        Test.stopTest();
    }
    
}
Hi all, I'm working on the InvocableMethod with Flow.  What it's supposed to deliver is put List<Id> in the apex action then return unique List<Id>. Here's the code.
public class lookUpAccountAnnotation {
   @InvocableMethod
    public static List<outputParam> getAccountIds(List<inputParam> param) {
        Set<Id> uniqueIds = new Set<Id>();
        uniqueIds.addall(param[0].inputIds);

        outputParam response = new outputParam();
        response.outputIds.addAll(uniqueIds);
        
        List<outputParam> outputs = new List<outputParam>();
        outputs.add(response);
        
        return outputs;
    }

    public class inputParam {
        @InvocableVariable(required=false label='AccountIDs for input')
        public List<Id> inputIds;
    }
    
    public class outputParam {
        @InvocableVariable(required=false label='AccountIDs for output')
        public List<Id> outputIds;
    }
}
With system.debug() in each variable, you can get the Ids for param and uniqueIds, but it seems it stopped by response before reaching system.debug (response)

Do you have any solution for this? It's pretty much generic wherever you can use inputting Ids and returning unique output Ids if this code works.

Thanks!

 
I'm working on Apex, and enconuter a problem how to check the blank value in integer varibale. Here're the codes.

Pass the number input from lightning:input to Apex Class.
component
<aura:attribute name="searchValue" type="Integer"/> 
                <div class="flex-item space-digit text-overflow-hide">
                <lightning:input
                    type="number"
                    name="Limit"
                    label="Value"
                    value="{!v.searchValue}"
                    onchange="{!c.onSearchTermChange}"
                />
                </div>


 
Switch the condition query in Dynamic SOQL, if !=null, then skip this WHERE clause.
 
Apex
if (searchValue!=null){
        searchQuery += ' AND Billing_Total__c=:searchValue ';
 }


 
However, this returns that default value of searchValue is null
If you entrer any value, it determined as !=null
If you erase the value and it's determied !=null but no value (blank?)

Do you know how to check if the Interger is blank?
I tried these but they didn't work.
if (searchValue!=null || String.isNotEmpty(String.valueOf(searchValue)))
if (searchValue!=null || String.isNotBlank(String.valueOf(searchValue)))
Thanks for your advice!

I have made a Lightning Component that lists all the nearby accounts based on the geo location of the specific account record. I added to list Leads as well by the same Class but the different method, but it only shows the Accounts, but not the Leads.

1. The component passes the recordId to the controller
2. the controller gets the accounts and lead back from Class
3. The controller returns the list of leads and accounts
4. The component shows the result of the list

I suppose the reason is the cmp.set(v.rows,rows); in the Controller seems overwriting previous values set. If anyone knows the best solution for this?

Class
public class MapNearbyLeadController {
	@AuraEnabled
    public static List<Account> getAccounts(String recordId){
		Lead lead = [SELECT Id,Latitude,Longitude,Industry,Sub__c FROM Lead WHERE Id = :recordId];        
        return [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet, BillingLatitude, BillingLongitude,Industry, Description, Related_Opportunities_y__c,Recent_Closed_Won_Date__c,Owner_Alias__c,Sub__c,Client_Type_new__c,Distance__c
                FROM Account 
                WHERE DISTANCE(BillingAddress, GEOLOCATION(:lead.Latitude,:lead.Longitude), 'km') < 6 AND Industry = :lead.Industry AND Sub__c = :lead.Sub__c ORDER BY Related_Opportunities_y__c DESC, DISTANCE(BillingAddress, GEOLOCATION(:lead.Latitude,:lead.Longitude), 'km') ASC LIMIT 30];
    }
    
	public static List<Lead> getLeads(String recordId){
		List<Lead> leads = new List<Lead>();
        leads = [SELECT Id,State,City,Street,Latitude,Longitude,Industry,Sub__c FROM Lead WHERE Id = :recordId LIMIT 1];
        return leads;        
    }
}

Component
<aura:component controller="MapNearbyLeadController" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    <lightning:navigation aura:id="navigation"/>
    <aura:attribute name="mapMarkers" type="Object"/>
    <aura:attribute name="rows" type="Map[]"/>
    <aura:attribute name="cols" type="Map[]"/>
    
    <aura:attribute name="selectedMarkerValue" type="String" />
    
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>   
    <div class="slds-box">
       <lightning:card title="Accounts Nearby" iconName="standard:account">
        <lightning:datatable
            data="{!v.rows}"
            columns="{!v.cols}"
            minColumnWidth="80px"
            wrapTextMaxLines ="2"
            sortable = "true"              
            keyField="Id"
            hideCheckboxColumn="true"
            showRowNumberColumn="true" />
    </lightning:card>
        </div>
</aura:component>
Controller
({
    init: function (cmp, event, helper) {     
        var cols = [
            {
                label: 'Name',
                fieldName: 'linkName',
                type: 'url',
                fixedWidth: 200,
                typeAttributes: {
                    label: {fieldName:'Name'},
                    target : '_blank'
                }
            },
            {
                label: 'Deal',
                fieldName: 'Related_Opportunities_y__c',
                fixedWidth: 80,
                type: 'number'
            },
            {
                label: 'Won Date',
                fieldName: 'Recent_Closed_Won_Date__c',
                fixedWidth: 120,
                type: 'date'
            },
            {
                label: 'Owner',
                fieldName: 'Owner_Alias__c',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'Client Type',
                fieldName: 'Client_Type_new__c',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'Industry',
                fieldName: 'Industry',
                fixedWidth: 100,
                type: 'text'
            },
            {
                label: 'State',
                fieldName: 'BillingState',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'City',
                fieldName: 'BillingCity',
                fixedWidth: 80,
                type: 'text'
            },
            {
                label: 'Street',
                fieldName: 'BillingStreet',
                fixedWidth: 200,
                type: 'text'
            }
        ];
        
        cmp.set( 'v.cols', cols );

        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getAccounts");
        action.setParams({recordId :recordId});           
        action.setCallback(this, function(response){
            
            var accounts = response.getReturnValue();
            var rows = [];
            for(var i = 0; i < accounts.length; i++){
                var acc = accounts[i];
                rows.push({
                    Id: acc.Id,
                    linkName: '/'+ acc.Id,
                    Name: acc.Name,
                    Industry: acc.Industry,
                    BillingState: acc.BillingState,
                    BillingCity: acc.BillingCity,
                    BillingStreet: acc.BillingStreet,
                    Related_Opportunities_y__c: acc.Related_Opportunities_y__c,
                    Recent_Closed_Won_Date__c: acc.Recent_Closed_Won_Date__c,
                    Owner_Alias__c: acc.Owner_Alias__c,
                    Client_Type_new__c:acc.Client_Type_new__c
                    });
            }
            
            if(rows.length != 0){
                cmp.set('v.rows', rows);
            }
        });     
/* 
  */     
        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getLeads");
        action.setParams({recordId :recordId}); 
        action.setCallback(this, function(response){
            
            var leads = response.getReturnValue();
            var rows = [];
            for(var i = 0; i < leads.length; i++){
                var ld = leads[i];
                rows.push({
                    Id: ld.Id,
                    linkName: '/'+ ld.Id,
                    Name: ld.LastName,
                    BillingIndustry: ld.Industry,
                    BillingState: ld.State,
                    BillingCity: ld.City,
                    BillingStreet: ld.Street,
                    Related_Opportunities_y__c: '',
                    Recent_Closed_Won_Date__c: '',
                    Owner_Alias__c: '',
                    Client_Type_new__c:''
                    });
            }
            
            if(rows.length != 0){
                cmp.set('v.rows', rows);
            }
        });
        
/*
*/  
        $A.enqueueAction(action);
    },

    handlerMarkerSelect: function (cmp, event, helper) {
        console.log(event.getParam("selectedMarkerValue"));
    }
});
Thanks in advance!

 
I've successfully plotted the accounts on Google Map with Lightning Component and it works in Sandbox...but don't know how to write a test code for the ApexClass.

I describe the codes below and hope anyone can help with the test code part. Thank you!

Component (MapNearbyAccount.cmp)
<aura:component controller="MapNearbyAccountController" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    <aura:attribute name="mapMarkers" type="Object"/>
    <aura:attribute name="selectedMarkerValue" type="String" />
    
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    
    <div class="slds-box slds-theme--default">
        <lightning:map 
                       mapMarkers="{! v.mapMarkers }"
                       selectedMarkerValue="{!v.selectedMarkerValue}"
                       markersTitle="accounts nearby"
                       listView="auto"
                       showFooter="false"
                       onmarkerselect="{!c.handlerMarkerSelect}" />
    </div>
</aura:component>
Controller (MapNearbyAccount.js)
({
    init: function (cmp, event, helper) {
        var recordId = cmp.get("v.recordId");     
        var action = cmp.get("c.getAccounts");
        action.setParams({recordId :recordId});
        cmp.set('v.mapMarkers', [{location: {}}]);

        action.setCallback(this, function(response){
            
            var accounts = response.getReturnValue();
            var markers = [];
            for(var i = 0; i < accounts.length; i++){
                var acc = accounts[i];
                markers.push({
                    location: {
                        Country : acc.BillingCountry,
                        State : acc.BillingState,
                        City: acc.BillingCity,
                        Street: acc.BillingStreet
                    },
    
                    icon : "standard:account",
                    value: acc.Id,
                    title: acc.Name,
                    description:acc.Description
                });
            }
            
            if(markers.length != 0){
                cmp.set('v.mapMarkers', markers);
            }
        });

        $A.enqueueAction(action);
    },

    handlerMarkerSelect: function (cmp, event, helper) {
        console.log(event.getParam("selectedMarkerValue"));
    }
});
ApexClass (MapNearbyAccountController)
public class MapNearbyAccountController {
    @AuraEnabled
    public static List<Account> getAccounts(String BillingCity, String BillingState, String recordId){
        Account acct = [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet, Industry FROM Account WHERE Id =:recordId];
        
        return [SELECT Id, Name, BillingCountry, BillingState, BillingCity, BillingStreet,Description
                FROM Account 
                WHERE BillingState = :acct.BillingState AND BillingCity LIKE :('%' + acct.BillingCity + '%') AND Industry = :acct.Industry LIMIT 10];
    }
}
TestClass
@isTest
public class MapNearbyAccountControllerTest {
@isTest
    static void testMapNearbyAccountController() {
        Account acc1 = new Account();
        acc1.Name='acc1';
        acc1.BillingCity='Shibuya';
        acc1.BillingState='Tokyo';
        insert acc1;
        
        MapNearbyAccountController ctrl = new MapNearbyAccountController();
        
        Test.startTest();
            List<Account> getAccounts = ctrl.getAccounts();
            System.assertEquals(false,getAccounts.isEmpty());
        Test.stopTest();
    }
    
}
I am trying to pass the value of an inputfield as Contact lookup field (Opportunity.Contact__c) from my Visualforce page (standardController = Opportunity) to my controller. 

I still don't figure out how the controller can receive the value from that Lookup value and its ID. It seems the Lookup field the datatype seems sObject, but Contact email_recipient can't receive it.

Similar post here but it doesn't help me, since I use the InputField value preset from Opportunity.Contact__c (Contact Lookup filed)
https://developer.salesforce.com/forums/?id=906F0000000MMDoIAO

Thanks for help!

VF (snippet)
<apex:form >
<apex:inputText html-placeholder="Subject" id="email_subject" value="{!email_subject}" />
<apex:inputtextarea html-placeholder="Body" rows="15" id="email_body" value="{!email_body}" />
<apex:inputField html-placeholder="Billing Contact" id="email_recipient" value="{!Opportunity.Contact__c}" />
<!-- this inputField value is from Contact Lookup filed of the Opportunity. This might be the cause of issue?? -->
          
<apex:pageBlock id="actions"> 
    <apex:param name="email_subjectText" assignTo="{!email_subject}" value="Authorization PDF"/>
    <apex:param name="email_body" assignTo="{!email_body}" value="Authorization PDF"/>
    <apex:commandButton action="{!SendPdf}" value="Send PDF"/>
</apex:pageBlock> 
</apex:form>
Controller (snippet)
public with sharing class PdfGeneratorController {
	public String email_subject {get;set;}
    public String email_body {get;set;}
    public String cont_email {get;set;}
	public Contact email_recipient {get;set;}

// this block turns error Compile Error: Illegal assignment from Schema.SObjectField to Contact
    email_recipient = new Contact();
    email_recipient = Opportunity.Contact__c;  // this might be wrong?
    cont_email = email_recipient.Email;
//

    public PageReference SendPdf() { 
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(new String[] {cont_email});
            mail.setSubject(email_subject);
            mail.setPlainTextBody(email_body);
            mail.setWhatId(parentId);
            mail.setEntityAttachments(Ids);
            Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});       
    }
}
Actual VF page look like. (red text is what's in VF code)
User-added image

 
I have defined a couple of Stages (Stage 1 and Stage 2) for my flow and embedded a component to show the stages in my 2 flow screens. When I start out on the first screen Stage 1 is correctly highlighted. However when I click Next to move to screen 2 I get this error that I cannot make sense of:

The delimiter of Stage 1 stage is missing.

I have not been able find any information about this cryptic error so I am hoping others have encountered it and know what it means or that SF can shed some light on what this means. 


 
Hello,

I have a Visualforce page, designed to generate PDF Document.
It looks like:
<apex:page standardController="Opportunity" showHeader="false" renderAs="pdf">
<h2 style="font-family: sans-serif; text-align: center;">My PDF</h2>
<p><strong>Soci&eacute;t&eacute; : </strong>{!Opportunity.Account.Name}<br />
    <strong>Nom : </strong>{!Opportunity.Amount}<br />
    <strong>Pr&eacute;nom : </strong>{!Opportunity.Amount}<br />
    <strong>Adresse : </strong>adresse</p>
</apex:page>

Using Lightning, I would like to:
  • Have a button on my Opportunity page, "Generate PDF"
  • On click, open an iframe over the same page, that displays the PDF (from the Visualforce page)
  • Have two buttons on this iframe: Save // Cancel
  • If I click save, it saves the PDF as a File, related to the current record
Any suggestions?
Thanks!