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
Gaston LeferGaston Lefer 

Default current contactid

var action = component.get("c.fetchUser");

            action.setCallback(this, function(response) {
                var state = response.getState();
                if (state === "SUCCESS") {
                    var storeResponse = response.getReturnValue();
                   // set current user information on userInfo attribute
                    component.set("v.userInfo", storeResponse);

                   // @@@@@ set default value here @@@@
                    var getContactId = component.get("v.userInfo.ContactId");
                    component.set("v.lookupcase.ContactId" , getContactId ) ;
            });
            $A.enqueueAction(action);


    <aura:attribute name="lookupcase" type="Case" default="{
            'sobjectType': 'Case',
            'ContactId': '',}"/>                                             
    <force:inputField value="{!v.lookupcase.ContactId}" class="slds-input"/>

Thsi doesn't works, what am I missing?
GauravGargGauravGarg
Hi Gaston,

Could you please try printing V.userInfo in console and check v.userInfo.Contactid is populate over there?

Thanks,
Gaurav
Skype: gaurav62990
Gaston LeferGaston Lefer
where, can you share the code?
GauravGargGauravGarg
Can we print value of v.userInfo below this line
 
component.set("v.userInfo", storeResponse


and check if v.userinfo actually gets updated or not.

Thanks,

Gaurav.

Gaston LeferGaston Lefer
var action = component.get("c.fetchUser");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
               // set current user information on userInfo attribute
                component.set("v.userInfo", storeResponse);

               // @@@@@ set default value here @@@@
                var getContactId = component.get("v.userInfo.ContactId");
                component.set("v.lookupcase.ContactId" , getContactId ) ;
                component.find("contactlookup").set("v.lookupcase.ContactId" , getContactId);
              
            }
        });
        $A.enqueueAction(action);
<force:inputField value="{!v.lookupcase.ContactId}" class="slds-input" aura:id="contactlookup"/>

Tring to default the contact id woth the cuurent user contact id (aura:id contact lookup)