+ Start a Discussion
Nandhini S 3Nandhini S 3 

Cannot read property 'success' of undefined

I'm using a javascript button to create a partner user account.
I'm getting the below error when i click the button.
'Cannot read property 'success' of undefined.

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
 if("{! Contact.Partner_User_Enabled__c}" == true )
{
alert( "Partner user already exists" );
}
else
{
var result = sforce.apex.execute("EnablePartnerPortal","createUser",{"partnerContact":'{!Contact.Id}'});
if(result[0].success == 'false')
{
alert("Account is not partner");
}
   
}
 window.location.href="/{!Contact.Id}";
VinayVinay (Salesforce Developers) 
Hi Nandhini,

Try below snippet.
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
 if("{! Contact.Partner_User_Enabled__c}" == true )
{
alert( "Partner user already exists" );
}
else
{
var result = sforce.apex.execute("EnablePartnerPortal","createUser",{"partnerContact":'{!Contact.Id}'});
if(result[0].success == 'false')
{
alert("Account is not partner");
}
else
{
window.location.href="/{!Contact.Id}";
}
   
}

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
KtHasNoLimitKtHasNoLimit
Hi Nandini,

It seems like ,the variable result doesn't have property success. Please check this by using the debugger or inspect the page. check whether the success is a property or not and what value is assigning to it.

I hope the above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Kirti Rathod