-1
<aura:attribute name="objDetail" type="GSS_User_Skill__c" default="{'sobjectType' : 'GSS_User_Skill__c'}" access="global"/>

Js side:

   var action =component.get("c.InsertUserSkills");
    alert('call--->'+JSON.stringify(component.get("v.objDetail")));
    action.setParams({
        "UserSkills":component.get("v.objDetail")
 });

In server side recieving value like this:

  @AuraEnabled
public static List<GSS_User_Skill__c> InsertUserSkills(sObject UserSkills){
  system.debug('Insert UserSkills---->'+UserSkills);}

Debug Log:

Insert UserSkills---->GSS_User_Skill__c:{Parameter__c=Severity, ValueText__c=1, ValuePick__c=1 - Critical, Level__c=1}

How can I access GSS_User_Skill__c values, If I access like this

         UserSkills.Parameter__c;

it shows Parameter__c undefined

0

When you declare a variable as an untyped sObject:

sObject UserSkills

you only get to access the fields and methods that are defined for sObject itself - such as the core get() and put() methods, and the Id field. Like with any other type in Apex, you cannot access member fields that don't exist on that type.

Declare, or cast, the correct type - GSS_User_Skill__c - and the compiler will allow you to access fields like Parameter__c. Alternately, you can use sObject's get() method, but it returns an Object, so you'll have to do a lot of casting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.