You need to sign in to do that
Don't have an account?
sreenivasApps
How to call a webservice method from a Html Home page component ? I am calling a class but its not working. Answers will be appreciated.
Below is my code written in html homepage component, i need logged in user profile.
<script src="/soap/ajax/28.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/28.0/apex.js" type="text/javascript"></script>
<script type="text/javascript">
setTimeout( function()
{
alert('entered in function');
var userProfile = sforce.apex.execute("UserProfileName", "getLoggedInUserProfile", {});
alert('userProfile'+userProfile);
if(userProfile != 'System Administrator')
{
var divObj = document.getElementsByClassName('bRelatedList');
if(divObj != null){
for(var i=0;i<divObj.length;i++)
{
var items = divObj[i].getElementsByTagName("a");
if(items != null )
{
for(var j=0;j<items.length;j++)
{
if(items[j].innerHTML=='Del')
{
items[j].style.display = "none";
}
}
}
}
}
alert('exit from function');
}, 1000);
</scrip>
first alert is getting displayed but from apex execute statement it is not executing.
here UserProfileName is class and getLoggedInUserProfile is static webservice method. when i call this method from console it is executing.
what is the wrong in my code i am not understanding why it is not calling the class ? please
<script src="/soap/ajax/28.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/28.0/apex.js" type="text/javascript"></script>
<script type="text/javascript">
setTimeout( function()
{
alert('entered in function');
var userProfile = sforce.apex.execute("UserProfileName", "getLoggedInUserProfile", {});
alert('userProfile'+userProfile);
if(userProfile != 'System Administrator')
{
var divObj = document.getElementsByClassName('bRelatedList');
if(divObj != null){
for(var i=0;i<divObj.length;i++)
{
var items = divObj[i].getElementsByTagName("a");
if(items != null )
{
for(var j=0;j<items.length;j++)
{
if(items[j].innerHTML=='Del')
{
items[j].style.display = "none";
}
}
}
}
}
alert('exit from function');
}, 1000);
</scrip>
first alert is getting displayed but from apex execute statement it is not executing.
here UserProfileName is class and getLoggedInUserProfile is static webservice method. when i call this method from console it is executing.
what is the wrong in my code i am not understanding why it is not calling the class ? please
tarunkumarsfdc1.3940961681216885E12
Make sure the class API version is also 28.0 becuase Salesforce is saving classes in 29.0 version API