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
jhonnajhonna 

Custom button rendering html

Hi,

  I am very new to Apex and Virtualforce developement.  Here is what I need to do.. I need directions to how to go about it.

 

I have a custom button on Account page called  List Assests from XXX webpage.  When i click on it,  I need to load a a  400 X300 iframe with external URL like www.xxx.com/assests?id={!account.id} some where in the page layout with a list of assetts . I cannot leave the page or load it in a new window.  This should re render, every time I click the button.

 

Do my question is how do I associate a custom object, custom field to a VF page and how do i make it rerender from a button on the Account Page and make sure it all remains in the same page layout.

 

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

here is complete solution for you... :)

 

Create custom button , Detail page button with content source as Javascript

 

Here is code for your script

 

 

var url="http://www.xxx.com/assests?id={!Account.Id}";
var a = [];var re = new RegExp('\\bpbHeader\\b');var els = document.getElementsByTagName("div");for(var i=0,j=els.length; i<j; i++)if(re.test(els[i].className))a.push(els[i]);var parent=a[0];
var e=document.getElementById("FrameLoader");
if(e==null)
{
var Errordiv = document.createElement('div');
Errordiv.setAttribute('id','FrameLoader');
Errordiv.setAttribute('title','Download complete');
Errordiv.innerHTML = '<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Assets Details  </p>';
parent.appendChild(Errordiv); 
var con=document.getElementById("FrameLoader");
var ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", url);
ifrm.setAttribute("frameBorder",0);
ifrm.style.width = 700+"px";
ifrm.style.height = 250+"px";
con.appendChild(ifrm); 
}

 

 

Special request Dont Play With Script Code ,

*** Just update your destination url..... :)

 

 

Cheers,

Bala 

All Answers

NBlasgenNBlasgen

I believe the answer is that you need to get tricky with Javascript.  I'd look at having a custom visualforce object on the screen that meets your height and width requirements.  Have the refresh button be on that VF page and in the VF page you can have your IFRAME.  You can then pass around a lot.

b-Forceb-Force

here is complete solution for you... :)

 

Create custom button , Detail page button with content source as Javascript

 

Here is code for your script

 

 

var url="http://www.xxx.com/assests?id={!Account.Id}";
var a = [];var re = new RegExp('\\bpbHeader\\b');var els = document.getElementsByTagName("div");for(var i=0,j=els.length; i<j; i++)if(re.test(els[i].className))a.push(els[i]);var parent=a[0];
var e=document.getElementById("FrameLoader");
if(e==null)
{
var Errordiv = document.createElement('div');
Errordiv.setAttribute('id','FrameLoader');
Errordiv.setAttribute('title','Download complete');
Errordiv.innerHTML = '<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Assets Details  </p>';
parent.appendChild(Errordiv); 
var con=document.getElementById("FrameLoader");
var ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", url);
ifrm.setAttribute("frameBorder",0);
ifrm.style.width = 700+"px";
ifrm.style.height = 250+"px";
con.appendChild(ifrm); 
}

 

 

Special request Dont Play With Script Code ,

*** Just update your destination url..... :)

 

 

Cheers,

Bala 

This was selected as the best answer
Imran MohammedImran Mohammed

Thanks Bala for sharing really a good solution.

b-Forceb-Force

Imaran,

I have few more ideas similar to this ,

adding into code receipies section very soon

 

Thanks,

Bala

Imran MohammedImran Mohammed

Thanks Bala, where can i find code recepies section?

Imran MohammedImran Mohammed

Bala,

 

I have one question, how can the scrollbars be removed as i think the code you posted will show up the scrollbars.

b-Forceb-Force

By precise adjusting of windows dimension ... we can remove them

 

Cheers,

Bala

b-Forceb-Force

will be available very soon in cookbook-->receipes section 

 

cheers,

Bala

jhonnajhonna

Thanks Bala. I had a followup question regardign a custom object linked to another object.

 

Here is my problem.

 

I have a custom boject linked to CASE called RASolution. They are linked by a  Lookup Relationship  which     Creates a relationship that links this RASolution to CASE object. The relationship field is the CASE NUMBER which links to the case id of Case.

 

Now for each case, I have to display the RASolution objects.. I am not sure how to do this. Any help regarding this will be highly appreciated.

 

Thanks.

Jyothi

b-Forceb-Force

if case and RASolution has a look-up  relationship , then you can display this RASolution records for each case by standard related List

 

go to case page layout --> related list section ---> drag and drop RASolution accordingly 


let me know if you are thinking something else...

 

Thanks,

Bala

jhonnajhonna

Thanks Bala. This is what I have done right now... I want to do a few things with this. like  auto refresh when another item is added to the list via another program using API or atleast refresh on a click of a button.

 

I thought I will use VF page to do that. Is that the right thing to do though?

 

I am new to SF developement. Please advice.

 

On another note, can we have multiple controllers on the same vf page?

jhonnajhonna

Also...

I wanted to know if Having a composite primary key was possible with Custom objects?


In my RASolution__c obkject,  I wanted to have Composite Primary Key  of Case number and Solution ID.  When Case number is of lookup type to Case Table.


I want to make sure the solution_id  of RASolution obect for each CASE remains unique.


In my custom RASolution object, I cannot make the Solution_id unique as multiple cases might have the same solution.

 

b-Forceb-Force

I  read this like ,

you are inserting anather Resolution record by button click

 

Create a Detail page button on Case object , with content source as javascript

Inside javascript use ajax toolkit create call

i.e.sforce.connection.create();

Reload the page by location.reload(true);

 

For one VF page no multiple controller

 

 

Cheers,

Bala

 

b-Forceb-Force

For Composite key query ,

Please put your requirement in more detail way, also explain current objects relationship

 

Cheers,

Bala