function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Koustav BanerjeeKoustav Banerjee 

custom coding

I am using a function to concatenate as follows in my lightning controller class 

getCompValue : function(component, event, helper) {
     
     var compVal = component.find("comp_id").get("v.value");
     var compValStr = '\'' + compVal + '\'';
     component.set("v.componentName", compValStr);
        
   },

but on save the value is becoming 
 'a2u180000003p27AAA'
Do you have any resolution on the same how to concatenate
' + <<variable>> + ' to get the result as 'a2u180000003p27AAA' 
Alain CabonAlain Cabon
Hi,

How do you save the value?  (apex or <force:recordData> ?)  
 
Koustav BanerjeeKoustav Banerjee
From the lightning controller class I am passing these values in a helper class which is in turn calling the server side controller class (Apex).
 
Sanjay Bhati 95Sanjay Bhati 95
Hi Koustav,

Please find below code that can help you,

1. Component
<aura:component controller="AccountController"  access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" >
	<aura:handler name="init" value="{!this}" action="{!c.doinit}" />
    <aura:attribute name="myVal" type="String"></aura:attribute>
</aura:component>

2. Controller
({
	doinit : function(component,event){
        var action1 = component.get("c.setConcatination");
        var compVal ='a2u180000003p27AAA';
        compVal = '<'+compVal+'>';
        action1.setParams({ con: compVal})
        action1.setCallback(this, function(a) {
            console.log(a.getReturnValue());
        });
        $A.enqueueAction(action1);
    }
})

3. AccountController
public class AccountController {
	@AuraEnabled
    public static Account accountDetail(String aid){
        Account accObject = [SELECT id,Name FROM account WHERE id =: aid];
    	return accObject;
    }
    @AuraEnabled
    public static void setConcatination(String con){
        system.debug('Concinate Id'+con);
    }
}

Please test and let me know