• AussieBattler
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 20
    Replies
Hi,

I want to redirect a user to a custom object if certain conditions are met.

So to that end, I have a trigger that is set off after a record is inserted or updated and this trigger calls a function in a class that handles the redirection. Everything works, all the code in the trigger and class is executing as I would expect, but instead of redirecting the user to the new screen it returns them to the newly saved record (as it would normally behave).

Any ideas where I am going wrong?

Trigger Code:
Code:
trigger testTrigger on Object__c (after insert,after update) {

Object__c[] obj = trigger.new;
if (obj[0].Picklist__c == 'Change') {
String objId = obj[0].uniqueID__c;
redirectClass.redirectFn(objId); 
}
}

Class Code:
Code:
public class redirectClass{

public static PageReference redirectFn(string uID) {
        Test__c sID = [SELECT Id FROM Test__c WHERE uID__c =:uID LIMIT 1];
 string currURL = '/' + sID.Id;
 PageReference redirect2 = new PageReference(currURL);
 redirect2.setRedirect(true);
 return redirect2;    
 }
}

 

 

Hi. Hopefully there is a simple solution.

I have created a custom object. When the user clicks on the tab for the custom object, the default list of items created for that object is displayed.

By default, when the user clicks on the link that directs them to the detail for the selected custom object. I want to change this so that the user gets redirected to a custom page I have built, which has a custom controller as well. I looked at doing it with a S-Control that pointed to the custom page but can't get see my custom page in the selection. From what I have read it looks like that  my custom page needs to use a non-custom controller if I want to do this.

Is this correct? Is there a work around I can use?

Many thanks.
Hi,

I created an Apex Component on Friday and it was working correctly. Today when I have tried to use it I am seeing the following error message:

Code:
Expression Error: Named Object: core.apexpages.components.cdk.ApexComponentRefHandler not found

 
I tried a few things but still got the error message. I have now tried to create another one, saved it and I did not change any of the default text that is automatically included when creating a new component. I then went to .../apexcomponent/test to continue working and the same error message is showing.

Has something changed since Friday? I can't quite understand why something was working but now isn't and even when I try to create a new component it still doesn't work.

Any help appreciated?


Hi. I have created a custom object (Enquiry__c) and when this object is created or updated I want it to create or update a Contact record. I have added a custom lookup field to the Contact object that captures the Enquiry__c unique ID.

I have got the creating part of the trigger working but am struggling on the update. If I try to update an Enquiry__c record I get an error message "MISSING_ARGUMENT, Id not specified in an update call". I realise I must need to locate the ID for the relevant Contact record but have not worked out how to do this. Following is my code:

Code:
trigger enquiryInsertContact on Enquiry__c (after insert, before update) {
List<Contact> contacts = new Contact[0];
if (Trigger.isInsert) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c,
     LastName = enq.Enquiry_Surname__c,
     Salutation = enq.Salutation__c));
  }
 insert contacts;
 }
else if (Trigger.isUpdate) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c));
  }
 update contacts;
 }
}

 If anybody coudl point me in the right direction it would be greatly appreciated.

Cheers.

Hi. I hope this is the right place for this enquiry. My application uses only custom objects.

I have generated the WSDL address for my APEX Application and get an address which looks like this:

https://na5.salesforce.com/soap/wsdl.jsp

When I put this WSDL inside Visual Studio by adding web reference, I got this error message:

The HTML document does not contain Web service discovery information.

Any idea how I could get a version that contain this Web service discovery information for Visual Studio?

Thanks
Hi. I like parts of the calendar/diary functionality used for events but most of it is superfluous to my needs. Is there anyway in Visualforce (using the Pages functionality) that I can create my own calendar/diary i.e.: use particular controls and data that is currently available?

I hope this makes sense.
Hi. I like the in-line editing functionality that is now provided and was wondering if it is possible to add this to the Pages functionality (i.e.: when you are creating your own pages and not using the standard screens)?
Hi. Perhaps I am over complicating this. I hope it is something simple I have missed.

Basically, I have a picklist on a page I have created and when the user changes the selection on the picklist I want to either show or hide parts of the screen (using ajax). My code below almost works (i.e.: the javascript function works but for some reason the variable I am storing the current state in appears to lose its value).

I have tried this a variety of ways but it always ends up with the same problem - I can see the value being assigned to the variable testval but when I want to render the section of the screen and make a call to get the testval value, the value has changed to being true all the time.

Can anybody assist?

Code:
<apex:page id="step4" controller="testpage" tabstyle="Enquiry__c">
<apex:form>
<script>
function currentval(id) {
var newval = document.getElementById(id).value;
switch (newval) {
case "1" :
var chgVal = '{!ToggleFalse}';
break;
default :
var chgVal = '{!ToggleTrue}';
break;
}
}
</script>

<apex:pageBlock title="test">
<apex:pageBlockSection title="test">
<apex:panelGrid columns="2" columnClasses="labelCol,dataCol">
<apex:outputLabel value="Picklist 1" for="picklist1"></apex:outputLabel>
<apex:inputField id="picklist1" value="{! testing.xyz__c}"></apex:inputField>
<apex:actionSupport event="onchange" onsubmit="currentval('{!$Component.picklist1}')" rerender="details"></apex:actionSupport>
</apex:panelGrid>
</apex:pageBlockSection>

<apex:outputPanel id="details">
<apex:pageBlockSection title="Details" rendered="{! hideshow}">
<apex:panelGrid columns="2" columnClasses="labelCol,dataCol">
<apex:outputLabel value="Name" for="personname"></apex:outputLabel>
<apex:inputField id="personname" value="{! testing.abcd__c}"></apex:inputField>
</apex:panelGrid>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>



Code:
public class testpage {

testing123__c testing;

boolean testval = false;

public String getToggleTrue() {
testval = true;
return null;
}

public String getToggleFalse() {
testval = false;
return null;
}

public testing123__c gettesting() {
if (testing == null) testing = new testing123__c();
return testing;
}

public Boolean gethideshow() {
return testval;
}

}


 


Hi. Is there a problem with displaying the actionStatus message when there are more than one partial page updates on a page?

I have a page which contains two output panels and one of the panels is updated depending on which commandlink is clicked. To be clear, the panels still do update correctly (using ajax) and display the content they are expected to show however the actionStatus message does not work. It was working when there was only one panel on the page.

In case it is important, in the code below the addPersonalDetails and addMoreDetails functions simply updates a variable. But as I say, it is working as I expect for both outputPanels but the actionStatus message does not display.

(Also, while I think of it, it would be very handy if the functionality existed to allow us to backup a page before we continued to work on it. Sort of a roll back type functionality).

Thanks.

Code:
<apex:pageBlock mode="detail">
<apex:facet name="header">
<apex:outputPanel>
<apex:commandLink action="{!addPersonalDetails}" title="Personal Details" rerender="personaldetails">Personal Details</apex:commandLink>
</apex:outputPanel>
</apex:facet>
<apex:outputPanel id="personaldetails">
<apex:actionStatus startText="Please wait...">
<apex:facet name="stop">
<apex:panelGrid columns="4">
<apex:outputText value="Gender"></apex:outputText>
<apex:outputText value="{!PersDetails.Gender__c}"></apex:outputText>
<apex:outputText value="Middle Name(s)"></apex:outputText>
<apex:outputText value="{!PersDetails.Middle_Names__c}"></apex:outputText>
<apex:outputText value="Date of Birth"></apex:outputText>
<apex:outputText value="{!PersDetails.Date_of_Birth__c}"></apex:outputText>
<apex:outputText value="Marital Status"></apex:outputText>
<apex:outputText value="{!PersDetails.Marital_Status__c}"></apex:outputText>
</apex:panelGrid>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:pageBlock>

<apex:pageBlock mode="detail">
<apex:facet name="header">
<apex:outputPanel>
<apex:commandLink action="{!addMoreDetails}" title="More Details" rerender="moredetails">More Details</apex:commandLink>
</apex:outputPanel>
</apex:facet>
<apex:outputPanel id="moredetails">
<apex:actionStatus startText="Please Wait...">
<apex:facet name="stop">
<apex:panelGrid columns="4">
<apex:outputText value="Date of Birth"></apex:outputText>
<apex:outputText value="{!moreDetails.Date_of_Birth__c}"></apex:outputText>
<apex:outputText value="Middle Name(s)"></apex:outputText>
<apex:outputText value="{!moreDetails.Middle_Names__c}"></apex:outputText>
<apex:outputText value="Date of Birth"></apex:outputText>
<apex:outputText value="{!moreDetails.Date_of_Birth__c}"></apex:outputText>
<apex:outputText value="Marital Status"></apex:outputText>
<apex:outputText value="{!moreDetails.Marital_Status__c}"></apex:outputText>
</apex:panelGrid>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:pageBlock>

 

Hi. I am sure this is a simple question. I have a simple SELECT query in my controller which brings back one record, but occasionally there may be no records for it to bring back. Everything works fine, except I need to know whether the query has retrieved data or not. And I'm not sure how I can test whether my query has retrieved data or not?

I have tried various methods but none seem to work. Any suggestions or examples?
Hi. I am sure this is something simple but I have had no success in getting it to work. I have tried two different approaches and can get neither to work.

Basically, I have two custom objects - a parent and child. I have created my own page and have bound fields to the child custom object. I click on save and everything works fine. However, when I add a lookup field on the child object (populated with the parent object records), I can populate it correctly but I cannot preselect the  relevant parent object value (insert the parent object id into the lookup field for the child object) which I can then save as part of saving the child object.

So the first approach I took was to populate the lookup field with the name value but when I tried to save the record it didn't work and I now realise it needs the ID value to be inserted into the database and not the name value. I have not been able to work out how to pre-select the lookup field with the ID for the parent object. I am assuming that once I can do this then it should save normally as before.

The second approach I thought would be simpler but still couldn't get it to work. Basically as the parent object ID is passed to the child object in the query string parameter I thought I would use it to populate the lookup field in the database (and not have this field show on the page I created). I can get everything to save but for whatever reason it doesn't save the ID value and instead treats it as a null and not the actual ID value. Any assistance would be greatly appreciated.

If this doesn't make sense please let me know and I will provide more information.

Snippets of my code on this approach follows:

Code:
ChildObject__c cObj;
static string parentId = System.currentPageReference().getParameters().get('id');

public PageReference save() {

cObj.ParentObjID__c = parentId;
insert cObj;
PageReference cObjPage = new PageReference('/' + cObj.id);
cObjPage.setRedirect(true);
return cObjPage;
}


public ChildObject__c getChildObj() {
If(cObj == null) cObj = new ChildObject__c();
return cObj;
}

public void setChildObj(ChildObject__c f) {}

 

Message Edited by AussieBattler on 10-29-2007 02:01 PM

Hi. This is probably very simple. I have created a trigger which updates some records upon a user clicking on the SAVE button, after the updates I then want to redirect them to a custom object (which depends on what they have selected before clicking on save). In other words, I don't want them to view the saved record but immediately be directed to a new create screen for another object.

I have everything working fine but I cannot work out how to direct them to the create page for a custom object? I would assume it is possible to do from within the trigger but I can't find out how. Any assistance appreciated.
Hi. Hopefully there is a simple solution.

I have created a custom object. When the user clicks on the tab for the custom object, the default list of items created for that object is displayed.

By default, when the user clicks on the link that directs them to the detail for the selected custom object. I want to change this so that the user gets redirected to a custom page I have built, which has a custom controller as well. I looked at doing it with a S-Control that pointed to the custom page but can't get see my custom page in the selection. From what I have read it looks like that  my custom page needs to use a non-custom controller if I want to do this.

Is this correct? Is there a work around I can use?

Many thanks.
Hi,

I created an Apex Component on Friday and it was working correctly. Today when I have tried to use it I am seeing the following error message:

Code:
Expression Error: Named Object: core.apexpages.components.cdk.ApexComponentRefHandler not found

 
I tried a few things but still got the error message. I have now tried to create another one, saved it and I did not change any of the default text that is automatically included when creating a new component. I then went to .../apexcomponent/test to continue working and the same error message is showing.

Has something changed since Friday? I can't quite understand why something was working but now isn't and even when I try to create a new component it still doesn't work.

Any help appreciated?


Hi. I have created a custom object (Enquiry__c) and when this object is created or updated I want it to create or update a Contact record. I have added a custom lookup field to the Contact object that captures the Enquiry__c unique ID.

I have got the creating part of the trigger working but am struggling on the update. If I try to update an Enquiry__c record I get an error message "MISSING_ARGUMENT, Id not specified in an update call". I realise I must need to locate the ID for the relevant Contact record but have not worked out how to do this. Following is my code:

Code:
trigger enquiryInsertContact on Enquiry__c (after insert, before update) {
List<Contact> contacts = new Contact[0];
if (Trigger.isInsert) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c,
     LastName = enq.Enquiry_Surname__c,
     Salutation = enq.Salutation__c));
  }
 insert contacts;
 }
else if (Trigger.isUpdate) {
 for (Enquiry__c enq : Trigger.new) {
  contacts.add(new Contact (FirstName = enq.Enquiry_First_Name__c));
  }
 update contacts;
 }
}

 If anybody coudl point me in the right direction it would be greatly appreciated.

Cheers.

Hi. Perhaps I am over complicating this. I hope it is something simple I have missed.

Basically, I have a picklist on a page I have created and when the user changes the selection on the picklist I want to either show or hide parts of the screen (using ajax). My code below almost works (i.e.: the javascript function works but for some reason the variable I am storing the current state in appears to lose its value).

I have tried this a variety of ways but it always ends up with the same problem - I can see the value being assigned to the variable testval but when I want to render the section of the screen and make a call to get the testval value, the value has changed to being true all the time.

Can anybody assist?

Code:
<apex:page id="step4" controller="testpage" tabstyle="Enquiry__c">
<apex:form>
<script>
function currentval(id) {
var newval = document.getElementById(id).value;
switch (newval) {
case "1" :
var chgVal = '{!ToggleFalse}';
break;
default :
var chgVal = '{!ToggleTrue}';
break;
}
}
</script>

<apex:pageBlock title="test">
<apex:pageBlockSection title="test">
<apex:panelGrid columns="2" columnClasses="labelCol,dataCol">
<apex:outputLabel value="Picklist 1" for="picklist1"></apex:outputLabel>
<apex:inputField id="picklist1" value="{! testing.xyz__c}"></apex:inputField>
<apex:actionSupport event="onchange" onsubmit="currentval('{!$Component.picklist1}')" rerender="details"></apex:actionSupport>
</apex:panelGrid>
</apex:pageBlockSection>

<apex:outputPanel id="details">
<apex:pageBlockSection title="Details" rendered="{! hideshow}">
<apex:panelGrid columns="2" columnClasses="labelCol,dataCol">
<apex:outputLabel value="Name" for="personname"></apex:outputLabel>
<apex:inputField id="personname" value="{! testing.abcd__c}"></apex:inputField>
</apex:panelGrid>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>



Code:
public class testpage {

testing123__c testing;

boolean testval = false;

public String getToggleTrue() {
testval = true;
return null;
}

public String getToggleFalse() {
testval = false;
return null;
}

public testing123__c gettesting() {
if (testing == null) testing = new testing123__c();
return testing;
}

public Boolean gethideshow() {
return testval;
}

}


 


Hi. Is there a problem with displaying the actionStatus message when there are more than one partial page updates on a page?

I have a page which contains two output panels and one of the panels is updated depending on which commandlink is clicked. To be clear, the panels still do update correctly (using ajax) and display the content they are expected to show however the actionStatus message does not work. It was working when there was only one panel on the page.

In case it is important, in the code below the addPersonalDetails and addMoreDetails functions simply updates a variable. But as I say, it is working as I expect for both outputPanels but the actionStatus message does not display.

(Also, while I think of it, it would be very handy if the functionality existed to allow us to backup a page before we continued to work on it. Sort of a roll back type functionality).

Thanks.

Code:
<apex:pageBlock mode="detail">
<apex:facet name="header">
<apex:outputPanel>
<apex:commandLink action="{!addPersonalDetails}" title="Personal Details" rerender="personaldetails">Personal Details</apex:commandLink>
</apex:outputPanel>
</apex:facet>
<apex:outputPanel id="personaldetails">
<apex:actionStatus startText="Please wait...">
<apex:facet name="stop">
<apex:panelGrid columns="4">
<apex:outputText value="Gender"></apex:outputText>
<apex:outputText value="{!PersDetails.Gender__c}"></apex:outputText>
<apex:outputText value="Middle Name(s)"></apex:outputText>
<apex:outputText value="{!PersDetails.Middle_Names__c}"></apex:outputText>
<apex:outputText value="Date of Birth"></apex:outputText>
<apex:outputText value="{!PersDetails.Date_of_Birth__c}"></apex:outputText>
<apex:outputText value="Marital Status"></apex:outputText>
<apex:outputText value="{!PersDetails.Marital_Status__c}"></apex:outputText>
</apex:panelGrid>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:pageBlock>

<apex:pageBlock mode="detail">
<apex:facet name="header">
<apex:outputPanel>
<apex:commandLink action="{!addMoreDetails}" title="More Details" rerender="moredetails">More Details</apex:commandLink>
</apex:outputPanel>
</apex:facet>
<apex:outputPanel id="moredetails">
<apex:actionStatus startText="Please Wait...">
<apex:facet name="stop">
<apex:panelGrid columns="4">
<apex:outputText value="Date of Birth"></apex:outputText>
<apex:outputText value="{!moreDetails.Date_of_Birth__c}"></apex:outputText>
<apex:outputText value="Middle Name(s)"></apex:outputText>
<apex:outputText value="{!moreDetails.Middle_Names__c}"></apex:outputText>
<apex:outputText value="Date of Birth"></apex:outputText>
<apex:outputText value="{!moreDetails.Date_of_Birth__c}"></apex:outputText>
<apex:outputText value="Marital Status"></apex:outputText>
<apex:outputText value="{!moreDetails.Marital_Status__c}"></apex:outputText>
</apex:panelGrid>
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
</apex:pageBlock>

 

Hi. I am sure this is a simple question. I have a simple SELECT query in my controller which brings back one record, but occasionally there may be no records for it to bring back. Everything works fine, except I need to know whether the query has retrieved data or not. And I'm not sure how I can test whether my query has retrieved data or not?

I have tried various methods but none seem to work. Any suggestions or examples?
Hi. I am sure this is something simple but I have had no success in getting it to work. I have tried two different approaches and can get neither to work.

Basically, I have two custom objects - a parent and child. I have created my own page and have bound fields to the child custom object. I click on save and everything works fine. However, when I add a lookup field on the child object (populated with the parent object records), I can populate it correctly but I cannot preselect the  relevant parent object value (insert the parent object id into the lookup field for the child object) which I can then save as part of saving the child object.

So the first approach I took was to populate the lookup field with the name value but when I tried to save the record it didn't work and I now realise it needs the ID value to be inserted into the database and not the name value. I have not been able to work out how to pre-select the lookup field with the ID for the parent object. I am assuming that once I can do this then it should save normally as before.

The second approach I thought would be simpler but still couldn't get it to work. Basically as the parent object ID is passed to the child object in the query string parameter I thought I would use it to populate the lookup field in the database (and not have this field show on the page I created). I can get everything to save but for whatever reason it doesn't save the ID value and instead treats it as a null and not the actual ID value. Any assistance would be greatly appreciated.

If this doesn't make sense please let me know and I will provide more information.

Snippets of my code on this approach follows:

Code:
ChildObject__c cObj;
static string parentId = System.currentPageReference().getParameters().get('id');

public PageReference save() {

cObj.ParentObjID__c = parentId;
insert cObj;
PageReference cObjPage = new PageReference('/' + cObj.id);
cObjPage.setRedirect(true);
return cObjPage;
}


public ChildObject__c getChildObj() {
If(cObj == null) cObj = new ChildObject__c();
return cObj;
}

public void setChildObj(ChildObject__c f) {}

 

Message Edited by AussieBattler on 10-29-2007 02:01 PM

Hi. This is probably very simple. I have created a trigger which updates some records upon a user clicking on the SAVE button, after the updates I then want to redirect them to a custom object (which depends on what they have selected before clicking on save). In other words, I don't want them to view the saved record but immediately be directed to a new create screen for another object.

I have everything working fine but I cannot work out how to direct them to the create page for a custom object? I would assume it is possible to do from within the trigger but I can't find out how. Any assistance appreciated.