You need to sign in to do that
Don't have an account?
Francesco Carmagnola 10
Expressions in literals - Pass SObject to a aura component with dynamic field value
I've created a component which accepts as an attribute an SObject. When I simply pass a JSON SObject to it, like:
But if I do that, I am passing a String instead of an SObject to the component.
Any idea? I want to keep the simplest as possible the component attribute structure.. So I can not create other attribute for the dynamic field values.
<c:ChildCreatorComponent obj="{ sobjectType : 'Contact', LastName : 'Rossi', FirstName : 'Mario' }" />Everything is fine. But right now, I need to pass a dynamic value (like an ID):
<c:ChildCreatorComponent obj="{ sobjectType : 'Contact', AccountId : MY_DYNAMIC_ID, LastName : 'Rossi', FirstName : 'Mario' }" />If I try to insert my ID with an expression, as I would do in Visualforce, I obtain an error. Example:
<c:ChildCreatorComponent obj="{ sobjectType : 'Contact', AccountId : {!v.recordId}, LastName : 'Rossi', FirstName : 'Mario' }" />"Cannot mix expression and literal string in attribute value, try rewriting like {!'foo' + v.bar}: Source"
But if I do that, I am passing a String instead of an SObject to the component.
Any idea? I want to keep the simplest as possible the component attribute structure.. So I can not create other attribute for the dynamic field values.