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
Varun MKVarun MK 

Lightning : Field Access in Server Side Controller

COMPONENT :-

<aura:attribute name="allegato" type="PT_Allegato__c" default="{'sobjectType':'PT_Allegato__c',
                    'SoftDelete__c': false}"/>

<lightning:buttonIcon iconName="utility:delete" variant="error" alternativeText="Elimina" onclick="{!c.deleteToBin}" size="medium"/> 

SERVER SIDE CONTROLLER :-

deleteToBin : function(component, event, helper) 
    {
    alert('Are you sure to delete?')
    console.log('SoftDelete__c');

        var all = component.get("v.allegato");
        var soft = component.get("v.allegato.SoftDelete__c"); 

        all.SoftDelete__c === true;   

        component.set("v.allegato",all);

        component.set("v.soft",true);     
       
    component.set("v.allegato.SoftDelete__c",true);
    }
})
Hello !
I want to set a field inside a object to true (Ref line : all.SoftDelete__c === true;  inside Server Contorller.

But it is not working as expected, Can any1 suggest what I am doing wrong ? 

 
Naveen KNNaveen KN
Hi Varun, 

The code which you mentioned above is the component or browser side code. I see that there is no logic to call apex code above. please design as mentioned below

1. you have to write an apex class with object update logic
2. refer that class and method in your lightning component
3. In the deleteToBin method of client side controller you have to invoke server side method by passing id of that record and the field value you need to update 
4. Take care of the object update logic in the server side apex code

Try this approach and post back in case if you see any issues. 

Naveen
Team codengine.in