+ Start a Discussion
Swamy P R NSwamy P R N 

how to give the api name in apex button logic for a un-managed package

Hi ,

Am created a un-managed package. Earlier my logic and everything works fine, when i created a this package entire sytem field,class apis are changed with some namespace prefix.
Actually i implemented a button logic to execute my apex class. Earlier it was executed, Now when i click on it was showing an error which is in below image. if i added name space prefix to class name also throwing same error.
class:

global class cls_RewardFeedSent{
     webservice static string rewardfeedsend(ID rewrdid){
       Reward__c rew =new Reward__c();
        rew = [select  id,name,Active__c,Rward_Amount__c,Time_Based_Mgmnt__c,User__c  from Reward__c where id=:rewrdid];
}
}
Button logic :

sforce.connection.sessionId = "{!$Api.Session_ID}";
var rwrd = '{!QnxSPM__Reward__c.Id}';
var result = sforce.apex.execute("cls_RewardFeedSent", "rewardfeedsend", {rewrdid:rwrd});
alert(result);

Can anybody suggest me the solution for this, Thanks in adavnce.
User-added image
Best Answer chosen by Swamy P R N
kiranmutturukiranmutturu
if a namespace has been defined for your organization, you must include it in the JavaScript code when you invoke the class.

For example, to call the above class, the JavaScript code from above would be rewritten as follows:
var contextUser = sforce.apex.execute("myNamespace.myClass", "getContextUserName", {});

All Answers

kiranmutturukiranmutturu
if a namespace has been defined for your organization, you must include it in the JavaScript code when you invoke the class.

For example, to call the above class, the JavaScript code from above would be rewritten as follows:
var contextUser = sforce.apex.execute("myNamespace.myClass", "getContextUserName", {});
This was selected as the best answer
Swamy P R NSwamy P R N
Its resolved dudes,

By adding namespaceprefix along with " . " i.e,
var result = sforce.apex.execute("namespaceprefix.cls_RewardFeedSent", "rewardfeedsend", {rewrdid:rwrd});