• guru87
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Dear Salesforce experts,

 

Below, I have a javascript function that adds/updates an account via the ForceTK library. This function creates a new account and contact based on an input form.

 

The issue I am facing is that I am trying to create a contact under the new account that was created, but wasn’t sure how to query the Id of the account that was created in order to set the AccountId field on the Contact. I have highlighted this line of code and it would be great if you could provide some advice as to what the proper syntax is.

 

function addUpdateAccount(e){

                e.preventDefault();

                var cId = $j('#accountId').val();

                var record = Accounts.findRecordById(cId);

                var cRecord;   

                if(record == null) { //new record

                    record = Accounts.create(['Id']);

                    cRecord = Contacts.create();

                }

                record.Name = $j('#name').val();

                record.Status__c = $j('#status').val();

                record.Phone = $j('#phone').val();

                record.Description = $j('#description').val();

               

                Accounts.sync(record);

               

                cRecord.FirstName = $j('#fName').val();

                cRecord.LastName = $j('#lName').val();

                cRecord.Email = $j('#email').val();

                cRecord.AccountId = record.Id;

               

                Contacts.sync(cRecord,successCallback);

                $j('#success').html('Save Successful');

            }

 

Thank you in advance and look forward to your responses.

 

Best Regards,

 

  • October 28, 2013
  • Like
  • 0

Dear Salesforce experts:

I have been trying to add a loading message screen on my visualforce pages during file upload using jQuery BlockUI.

I've got as far as showing a loading animation during the file upload process, but soon after the animation is shown, I get the following error message:

 

"apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute."

 

It appears I cannot use apex:InputFile in conjunction with the oncomplete attribute in my code. 

Does anyone know of a workaround to make the loading screen appear during file upload?

 

Here is my code below:

 

<apex:page standardController="Account" extensions="CustomController" standardStylesheets="false">

    <head>
      <apex:includeScript value="{!$Resource.jquery}"/>
      <apex:includeScript value="{!$Resource.jqueryblockUI}"/>
     
      <script type="text/javascript">
     
         j$ = jQuery.noConflict();
        
           function blockme() {
               j$.blockUI({message: '<img src="{!URLFOR($Resource.ajax_loader)}">'});   
             }  
                      
      </script>  
     </head>
     
     <apex:form enctype="multipart/form-data">
     <!-- ... extra code -->

      <apex:commandButton action="{!Save}" value="Save" onclick="blockme()" oncomplete="j$.unblockUI();"/>

     <!-- ... extra code -->

     </apex:form>
</apex:page>

 Any advice would be much appreciated!! =)

 

 

  • October 22, 2013
  • Like
  • 0

Dear Salesforce experts,

I was having issues with copying text over from an inputfield to a textfield upon clicking on a checkbox.

The current visualforce page contains an inputfield (Id=companyId in the code below) that consists of a lookup to a company. This field is rendered if the "Create New" checkbox is not checked.

Upon clicking on the checkbox, the inputfield is replaced by a textfield for the user to enter the company name. At this very moment, the textfield that is rendered needs to be auto-populated with the text that was entered in the inputfield. I have attempted to use javascript to accomplish this, but so far have had no luck.

  

Visualforce page below:

 

<apex:page controller="CompanyUpdate" deferLastCommandUntilReady="true" >
    <script>
    function setObjectValues(input, companyId, companyText) {
 
        if(input.checked) {
            document.getElementById(companyText).value = document.getElementById(companyId).value; //copy the inputfield value over to the text field
            document.getElementById(companyId).value = ''; //set company lookup field to blank, to avoid the lookup validation
        }
    }
    </script>
   
    <apex:form >
        <apex:pageBlock >
            <apex:outputPanel id="entryPanel">
                <apex:pageBlockSection columns="1" collapsible="false"> 
                    <apex:pageBlockTable value="{!newUpdates}" var="n" width="100%" cellpadding="2" cellspacing="0" columnsWidth="30%,70%" styleClass="summaryTable">
                        <apex:column headerValue="Company">
                            <apex:inputField id="companyId" value="{!n.entry.Company__c}" rendered="{!NOT(n.create)}" />
                            <apex:inputText id="companyText" value="{!n.company}" rendered="{!(n.create)}"/>
                            <apex:outputLabel value="Create New" for="create"/>
                            <apex:inputCheckbox value="{!n.create}" id="create"  onchange="setObjectValues(this,'{!$Component.companyId}','{!$Component.companyText}');">
                                <apex:actionSupport event="onclick" rerender="entryPanel"/>
                            </apex:inputCheckbox>
                        </apex:column>
                    </apex:pageBlockTable>
                 </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  If anyone could provide some advice, it will be much appreciated! Thanks in advance!

 

  • October 10, 2013
  • Like
  • 0

Dear Salesforce experts,

I was having issues with copying text over from an inputfield to a textfield upon clicking on a checkbox.

The current visualforce page contains an inputfield (Id=companyId in the code below) that consists of a lookup to a company. This field is rendered if the "Create New" checkbox is not checked.

Upon clicking on the checkbox, the inputfield is replaced by a textfield for the user to enter the company name. At this very moment, the textfield that is rendered needs to be auto-populated with the text that was entered in the inputfield. I have attempted to use javascript to accomplish this, but so far have had no luck.

  

Visualforce page below:

 

<apex:page controller="CompanyUpdate" deferLastCommandUntilReady="true" >
    <script>
    function setObjectValues(input, companyId, companyText) {
 
        if(input.checked) {
            document.getElementById(companyText).value = document.getElementById(companyId).value; //copy the inputfield value over to the text field
            document.getElementById(companyId).value = ''; //set company lookup field to blank, to avoid the lookup validation
        }
    }
    </script>
   
    <apex:form >
        <apex:pageBlock >
            <apex:outputPanel id="entryPanel">
                <apex:pageBlockSection columns="1" collapsible="false"> 
                    <apex:pageBlockTable value="{!newUpdates}" var="n" width="100%" cellpadding="2" cellspacing="0" columnsWidth="30%,70%" styleClass="summaryTable">
                        <apex:column headerValue="Company">
                            <apex:inputField id="companyId" value="{!n.entry.Company__c}" rendered="{!NOT(n.create)}" />
                            <apex:inputText id="companyText" value="{!n.company}" rendered="{!(n.create)}"/>
                            <apex:outputLabel value="Create New" for="create"/>
                            <apex:inputCheckbox value="{!n.create}" id="create"  onchange="setObjectValues(this,'{!$Component.companyId}','{!$Component.companyText}');">
                                <apex:actionSupport event="onclick" rerender="entryPanel"/>
                            </apex:inputCheckbox>
                        </apex:column>
                    </apex:pageBlockTable>
                 </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  If anyone could provide some advice, it will be much appreciated! Thanks in advance!

 

  • October 10, 2013
  • Like
  • 0