3

I have 2 visual force page that I need to pass value from each other. First visual force page is for opportunity edit page. In this page I have a picklist field called Type . Value of this field are One, Two, Three.

There is another field called car and its type is lookup on the Opportunity edit visual fource page. When someone clicks on this lookup I am redirecting them to visualforce page called Carlookup . On this Carlookup visualforce page I want the value of Type from previous page which has been selected by user.

Let me clarify few things here .

In my org I use openPopup() function and pass paramenters into that like baseURL,Width,Heigh

where Variable baseurl is what I have created for different fileters in that lookup page.

Here is the code for Baseurl

var BaseURL="/apex/Looup?txt=" + txt; 

if(Cond.) 
    {baseurl = baseurl + "&txt2=" document.getElementbyId(page:form:pbs:carvalue).value; 

i have tried adding another condition for type

if(opp.type != null) baseurl = baseurl+"&type=" + document.getElementbyId(page:form:pbs:Type).value; }

but this does not go inside if(opp.type != null) even if it is not null. I have debugged that by looking at the gerated url and it does not have no parameter called type.

Anyone please can help me with this? Any suggestion is greatly appreciated.

  • Try with if({!opp.type} != null) – Himanshu Oct 21 '15 at 12:38
1

it should work in following way

if('{opp.type}'!= null){
     baseurl = baseurl+"&type=" +document.getElementbyId("page:form:pbs:Type").value;
}

Edit:

To address openpoup() function having stopped working, try the following and check console for errors:

if(document.getElementbyId("page:form:pbs:Type").value!= null){ baseurl =
baseurl+"&type=" +document.getElementbyId("page:form:pbs:Type").value; } – 
  • let me know if you see any error in console. – Himanshu Oct 21 '15 at 12:49
  • I did that and now openpoup() function has stopped working. it doesn't open the poup anymore. – Ricky Oct 21 '15 at 12:57
  • there is no error in console – Ricky Oct 21 '15 at 12:57
  • do you see any error in error console ? – Himanshu Oct 21 '15 at 12:58
  • No. There isn't any error in console – Ricky Oct 21 '15 at 13:01
1

I think you are not refreshing your JavaScript when opp.Type value is update . So pass this value when you call this Javascript method. Something like

popup('{opp.type}')

Also check you are getting picklist value in your code or you can try something like.

var e = document.getElementById("page:form:pbs:Type");
var strValue = e.options[e.selectedIndex].value;

and then pass this value in Parameter. So your complete Javascript method will look like

function popup(type) {
   var e = document.getElementById("page:form:pbs:Type");
    var strValue = e.options[e.selectedIndex].value;
    if(type != null){
        baseurl = baseurl+"&type=" +strValue ;
   }
}
  • Hey Tushar. Where can I use popup('{opp.type}') – Ricky Oct 21 '15 at 13:36
  • I already have one openpopup() in which I am passing baseurl width etc. – Ricky Oct 21 '15 at 13:37
  • from where you are calling your JavaScript method. pass value from your method openpopup('{opp.type}') – Tushar Sharma Oct 21 '15 at 13:39
  • This is my Openpopup function openPopup(baseURL, "lookup", 350, 480, "width="+width+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); should I add into this? – Ricky Oct 21 '15 at 13:41
  • yes add into this. – Tushar Sharma Oct 21 '15 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.