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
HydHyd 

Reg: Java Script Code

Hi,

 

I create 2 objects. Department (P) & Employee (C).

Here Employee Have Look up relation with Department(p).

My requirement is,

 

I created a Detail Page Button on Employee Object.

When i click on This button i would like to display the look up record in Master object.

 

I tried it through the customization. I got the solution.

But i want to solve this problem either by  javascript or by any other way.

 

please reply...

 

Thanks...

 

 

 

LionLion

Code in Apexclass:-

 

global Class ButtonClick
{
    WebService static string jsValue(String sId)
    {        
        child__c Obj = new child__c();
        Obj=[select id,name,department__c from child__c where id=:sId ];
        string strRef = 'https://ap1.salesforce.com/'+Obj.department__c;       
        return strRef;
    }
}

 

 

 

Code in Button:-

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var c = new sforce.SObject("child__c"); 
c.id = "{!Child__c.Id}"; 

var ref = sforce.apex.execute("ButtonClick","jsValue", {sId : c.id}); 

window.location = ref