• Amphro
  • NEWBIE
  • 75 Points
  • Member since 2009

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 40
    Replies

Is there a way using javascript to programmatically submit a form as if a user clicked on a <apex:commandButton> component?

 

Take the simple vf page

 

<apex:page controller="TestPerms" ><apex:commandButton id="theSectionItem2" value="Search" action="{!testInsert2}" /></apex:page>

 

Is there a way via javascript to submit this form as if they clicked on the submit button? 

 

  • September 02, 2009
  • Like
  • 0

I created a customer object called New Call Log. The call log is related to Solutions object where solutions is the parent. I am trying to create a VF page with Call log is the controller. A rep would enter in the information regarding the call and on the same page the Solution is shown below the call. I have been trying to work with sample code from the Recruiting application but it isn't working. This is what I have so far.

 

<apex:page standardController="New_Call_Log__c" id="thePage" showHeader="false"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!quickSave}" reRender="out, in" status="status"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockSection columns="1"> <apex:inputField value="{!New_Call_Log__c.Who_is_Calling__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Reason_for_Call__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Additional_Details__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Date_of_Call__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Name_of_Caller__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Callers_Email__c}"></apex:inputField> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Solutions"> <apex:pageBlockTable value="{!New_Call_Log__c.solution__r}" var="JA" title="Solutions"> <apex:column value="{!JA.Solution__r.SolutionNote"></apex:column> <apex:column Value="{!JA.Soluiton__r.Incident_Reason__c"></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

 

Any help would be very appreciated.

<apex:commandButton onclick="return confirm('Are you sure?')" action="{!myaction}" value="Do This!" />

 

Previously, it would ask if you wanted to confirm your action, and then do it. As of a day or two ago, using this exact method causes it to not perform the action. Removing the onclick causes it to work correctly again. Anyone else having this problem?
  • September 01, 2009
  • Like
  • 0

I've managed to get a google visualization gauge on an vf page, and it seems to work in all browsers (Safari, Mozilla, IE < 8) except IE 8, unless I view the page in compatibility mode.  For the life of me, I don't see anything going wrong, no errors in the javascript, just no image.

 

Has anyone else run into this problem and might have a solution?

What I am trying to do is determine if a Lead or Contact exist and they don't then add them as a new Lead.

 

Here is the Apex Class

 

global class getcontactinfo {

 Webservice static Contact getcontactemail(string Contact) {
 contact c = [Select Phone,Email from Contact where Email = :Contact];
 
    return c;
}
}

 

 

So what I am doing to calling this global class from within ASP.net VB.

 

If the users e-mail does not exist it is giving me this error : System.QueryException: List has no rows for assignment to SObject.

 

If the users e-mail does exist then I am getting this error : System.QueryException: List has more than 1 row for assignment to SObject

 

I need to get a value passed back to my ASP.net page so that I can either add them using the Web2Lead or not add them as a lead cause there e-mail exist already.

 

 

 

  • September 08, 2009
  • Like
  • 0

Hi All,

 

I have three action methods in different controllers which inserts records in three different objectsI am invoking the action methods through JavaScript (using ActionFunction Tag). i have some Standard validation rules on the three objects. When i am invoking the first action method using JavaScript, If an exception comes (Validation Rules) the second action method should not invoke.

 

Since it is a JavaScript all the action methods are getting called one by one even though exception(Validation Rules) occurs in the first action methods and error messages on the visualforce screen are being displayed and getting vanished.

 

So please suggest how to stop the JavaScript function if an exception occurs in the controllers.

 

Thanks

Srikanth.K 

 

 

 

I have create a field of type checkbox, and selected as default checked. Is it possible that it will appear as checked in VisualForce page on new form, by using <apex:inputField>

 

Thanks,

Raj

Hi,

           I have created a mass update button on custom object using Visualforce. Visualforce page works fine but we need to have alert message (Select the row you want to update) on custom button on the list page.

Can someone guide me through this with sample code as I am new to Visualforce and Javascript.

Thanks

Hi,

    I am retriving ID based on Query String .Now i need to list all the sObjects dynamically based on that ID inorder to know to which sObject that Id belongs and retrive record from that sObject.I guess we can do this with SOSL Query but dont know how to proceed.Pls Provide me Query or any process to do this.

 

Pls do the needful.

Here's the scenario: I have a custom object ('project') that is created via apex when an Opportunity is closed. I am trying to establish a 1:1 relationship (at least from the user's perspective), so I want the newly created project to be passed back to a lookup on the Opportunity.

Basically, I'm seeking to populate the Opportunity Project lookup with the id of the newly created project record so that they are linked both ways (instead of just linking one way, the project back to the opportunity).

I assume this can be done in an afterinsert trigger on the project object. But, I have been unable to update a related object via my trigger.

Something like this: thisOpp.Parent_Opportunity__r.Project_Profile__c = Project_Profile__c.Id;

I'm offering $65 via paypal to the first person that can provide me a working answer (this would include an apex trigger and the basic structure of a test class or an alternative solution).

Contact me with questions. (I will be working over the weekend.)

Message Edited by J Baze on 09-04-2009 05:21 PM

I have a simple query of a custom object.  It is showing the correct number of records(3), but the fields are blank.

 

 

Public List<TestObject__c> specialists;

 

public List<TestObject__c> getSpecialists() { return specialists; } public PageReference search(){ specialists = Database.query('select AnimalType__c from TestObject__c'); return null; }

 

 

 

 

<apex:form > <apex:commandButton action="{!search}" value="Search" /> </apex:form> <apex:dataList var="s" value="{!specialists}" id="list"> Type: <apex:outputText value="{!s.AnimalType__c}" /> </apex:dataList>

 


 

  • September 04, 2009
  • Like
  • 0

I have written a simple trigger that populates a custom lookup field on the Contact object with the Data from a Standard lookup field on the Account object.

 

I am having some issue testing this trigger as everytime I try to create a dummy contact to test on I get an error.

 

Here is the trigger:

 

trigger PopulatePracticeContact on Contact (before update, before insert) { //Set of Account Ids Set<Id> AccountIds = new Set<Id>(); for (Contact contactNew : Trigger.new) { AccountIds.add(contactNew.AccountId); //A set of Accounts } Map<Id, Account> pAccounts = new Map<Id, Account>([SELECT a.id, a.parentid, a.Name FROM Account a WHERE a.id IN :AccountIds]); for(Contact fcon : Trigger.New){ fcon.Related_Practice_Account__c = pAccounts.get(fcon.AccountId).ParentId; } }

 

 

Here is what I have started for the Test Class... I am not really sure how to test this anyway, so any suggestions would be greatly appreciated.

 

public with sharing class PopulatePracticeContactTest {

  static testMethod void PopulatePracticeContactTest(){

 

Account pAcc1 = new Account(Name = 'TestAccount1', BillingState = 'MN', Practice_ID__c = '1234', Operational_status__c = 'Prospect', recordTypeId = '012700000009R7B');

insert pAcc1;

Account fAcc1 = new Account(Name = 'TestAccount2', BillingState = 'OH', Facility_ID__c = '4321', Operational_status__c ='Pending', recordTypeId = '012700000009R7G', ParentId = pAcc1.id);

insert fAcc1;

 

Contact pCon1 = new Contact(LastName = 'TestContact1', AccountId = pAcc1);

insert pCon1;

Contact fCon1 = new Contact(LastName = 'TestContact2', AccountId = fAcc1);  insert fCon1;

 

}

}

 

The error that I get is this:

 

Save error: Invalid initial expression type for field Contact.AccountId, expecting: Id PopulatePracticeContactTest.cls 

 

Update: I didn't review this before I posted it - I did make a copy/paste error I just pasted the trigger twice.  The test class that I actually started writing is now added.

Message Edited by MSVRad on 09-08-2009 06:44 AM
  • September 03, 2009
  • Like
  • 0

I recently learned that classes in apex inherit a toString method which outputs the instantiated object to a string (much like serialization does in some languages). I cannot seem to find any documentation on this inherited method can someone point me in the right direction? 

 

Also once its in a string how can then convert that string to an object again?

 

Thanks 

Message Edited by jadent on 09-02-2009 11:52 AM
  • September 02, 2009
  • Like
  • 0

I created a customer object called New Call Log. The call log is related to Solutions object where solutions is the parent. I am trying to create a VF page with Call log is the controller. A rep would enter in the information regarding the call and on the same page the Solution is shown below the call. I have been trying to work with sample code from the Recruiting application but it isn't working. This is what I have so far.

 

<apex:page standardController="New_Call_Log__c" id="thePage" showHeader="false"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!quickSave}" reRender="out, in" status="status"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockSection columns="1"> <apex:inputField value="{!New_Call_Log__c.Who_is_Calling__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Reason_for_Call__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Additional_Details__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Date_of_Call__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Name_of_Caller__c}"></apex:inputField> <apex:inputField value="{!New_Call_Log__c.Callers_Email__c}"></apex:inputField> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Solutions"> <apex:pageBlockTable value="{!New_Call_Log__c.solution__r}" var="JA" title="Solutions"> <apex:column value="{!JA.Solution__r.SolutionNote"></apex:column> <apex:column Value="{!JA.Soluiton__r.Incident_Reason__c"></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

 

Any help would be very appreciated.