• Duncan_Idaho
  • NEWBIE
  • 95 Points
  • Member since 2010

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

Hi ,

 

I haave a requirement when i populate 3 picklist hierarchical using code. Its working fine but i get duplicates.

 

Example :   xyz

                     xyz

                    abc

 

My code to populate one of the picklist is given below. This gets the elements from a field in the object and i get the value from it by iterating. My issue is i need to eliminate duplicates.

 

      public List<selectOption> getLanguageList() {
     
              List<selectOption> options = new List<selectOption>();
   
         for (List<NKJ_EmailTemp_Classify__c> listMapping : [select Language__c
                                                               from NKJ_EmailTemp_Classify__c 
                                                               where Certificate_Brand__c = :selectedBrand])
                                                            
          {
           for (NKJ_EmailTemp_Classify__c obj:  listMapping) {
               options.add(new selectOption(obj.Language__c, obj.Language__c));
           }
        
          }
            system.debug(options);
            return options ;             
      }

 

Note >> Blue are my custom objects where i select and in the innerloop i iterate over the fields to generate by options list.

  • March 09, 2011
  • Like
  • 0

Hi,

 

 

I am trying to display a message when checbox in my Visual force page is checked. I am using action support for my check box component. The re rendering part the section is working, but the set property of the checkbox  is not getting invoked i.e. I am not able to capture the checkbox value if its checked or unchecked.

 

Below is my source code. Thanks in advance

 

Controller

 

public Boolean specialInvest{

      get{

            if(specialInvest == null){

                  specialInvest = true;

            }

                       

            return specialInvest;  

      }

      set;

    }

 

 

Visual Force page

 

<apex:page standardController="Case" extensions="RMAEditPageController" action="{!pageLoad}">     
<script>


    var windowRef;
    var intervalId = 0;
    var globalObj;
    function openLookUpWindow(obj){
        //alert(obj);  
        var ele = document.getElementById(obj);
        var accId = document.getElementById("j_id0:rmaForm:block:RMASection:AccountNameItem:AccountName_lkid").value;
        //alert(accId);
        checkToOpenWindow(accId)
        //setTimeout(checkToOpenWindow, 2*1000);
    }
   
    function checkToOpenWindow(accountId){
        windowRef = window.open('/apex/lookUp?id='+accountId,'','width=500, height=300, scrollbars=yes, resizable=yes, menubar=no, status=no,toolbar=no');
        //checkWindowStatus();
    }
               
              
</script>
  <apex:form id="rmaForm" >
        <apex:pageMessages />
        <apex:pageBlock mode="edit" id="block" rendered="true" >
                <apex:pageBlockButtons location="both">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!saveAdd}" value="Save & Add or Mass Upload RMA Item"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
           
            <apex:pageBlockSection id="RMASection" title="RMA" columns="2" >
                <apex:pageBlockSectionItem id="AccountNameItem">
                    <apex:outputLabel for="AccountName">Account Name</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField required="true" id="AccountName" value="{!Case.AccountID}" />
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="ReturnTypeItem">
                    <apex:outputLabel for="ReturnType">Return Type</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField required="true" id="ReturnType" value="{!Case.Return_Type__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="ShipToItem">
                    <apex:outputLabel for="ShipTo">Ship To</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputText value="{!shipToNum}" id="ShipTo" onclick="javascript&colon;openLookUpWindow('{!$Component.RMASection}');" >
                        </apex:inputText>
                        <apex:commandButton reRender="ShipTo" action="{!lookUp}"  image="{!$Resource.lookupIcon}"  onclick="javascript&colon;openLookUpWindow('{!$Component.RMASection}');"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="InvoiceToItem">
                    <apex:outputLabel for="InvoiceTo">Invoice To</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="InvoiceTo"  value="{!Case.Invoice_To1__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
                               
                <apex:pageBlockSectionItem id="CustomerPOItem">
                    <apex:outputLabel for="CustomerPO">Customer PO</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="CustomerPO"  value="{!Case.Customer_PO__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="ContactNameItem">
                    <apex:outputLabel for="ContactName">Contact</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="ContactName"  value="{!Case.ContactID}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                 <apex:pageBlockSectionItem id="DescriptionItem">
                    <apex:outputLabel for="Description">Description</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="Description"   value="{!Case.Description}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="SpecialInvestigationItem">
                    <apex:outputLabel for="SpecialInvestigation">Special Investigation</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputCheckbox id="SpecialInvestigation"   value="{!specialInvest}">
                            <apex:actionSupport event="onclick" reRender="note"/>
                        </apex:inputCheckBox>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

               
                 <apex:pageBlockSectionItem id="StatusItem">
                    <apex:outputLabel for="Status">Status</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:outputField id="Status"  value="{!Case.Status}" />
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

                </apex:pageBlockSection>
           
                           
                <apex:pageBlockSection title="Order Numbers" columns="2" id="OrderNumberSection">
                <apex:pageBlockSectionItem id="OrderNumberItem">
                    <apex:outputLabel for="OrderNumber">Order Number</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="OrderNumber"  value="{!Case.Original_Order_Number__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

                 <apex:pageBlockSectionItem id="OrderLineNumberItem">
                    <apex:outputLabel for="OrderLineNumber">Order Line Number</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="OrderLineNumber"  value="{!Case.Original_Order_Line_Number__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
              </apex:pageBlockSection>
              </apex:pageBlock>
              <apex:pageBlock id="note">
                  <apex:pageMessages id="msg" rendered="{!specialInvest}"></apex:pageMessages>
              </apex:pageBlock>
          </apex:form>   
</apex:page>

 

 

 

  • December 23, 2010
  • Like
  • 0

Hi,

 

I am calling a controller function using apex:commandlink

 

<apex:commandLink action="{!Next}" rendered="true" reRender="CustomList">{!showNext}</apex:commandLink>

 

When using Firefox browser function call is working properly, but with IE control again goes to <init> and next() function is not called.

 

Also, the viewstate is not maintained when using IE. Crippled around this for many days,  can somebody please advice.

 

Thank in advance.

 

Aditya

 

I'm trying to write some test code for some RemoteAction methods that insert feed items. The test code is querying the newsfeed and not finding the feeditems I've inserted. 

 

Is there a time delay between feeditems being posted and them appearing in the newsfeed?

	function postImage(imageURL){
		
		var image = document.createElement('img');
	        var canvas = document.createElement('canvas');
		
		image.onload = function(e){
		  	console.log('Attempting image post');		  	

		    canvas.width = image.width;
		    canvas.height = image.height;		  
	
		    var ctx = canvas.getContext("2d");
		    ctx.drawImage(image, 0, 0);		  	
		    var dataURL = canvas.toDataURL("image/png");		
		    dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
		    console.log('length of image blob: ' + dataURL.length);
		  	
		    ht_ccRemotes.postPinnedImage(dataURL,function(result,event){
		    	
		        if(event.type == 'exception'){
		            console.log('Error pinning image: ' + event.message);
		        }else{
		        	console.log('Successful image pin');
		        }
		    });   
	    }
	    
		image.crossOrigin = 'anonymous';
		image.src=imageURL;	 
   }

Within visualforce, the above javascript results in the error "Cross-origin image load denied by Cross-Origin Resource Sharing policy." when fed an image url for an external domain, even though I'm setting the crossOrigin attribute to anonymous. Does Salesforce have any special CORS restrictions?

Looks like there's a way to do this in the chatter rest api, but I can't figure out how to do it in SOQL.

I've been doing some tech screening for a senior developer position. In my opinion, these are more high mid level questions that a senior developer should have no trouble with. My goal is to make sure the developer has an understanding of salesforce as a whole, not just coding.

 

1. Explain the difference between Role and Profile security.

2. Give at least two use cases for Salesforce Chatter.

3. I have two custom objects, custom object 1 & custom object 2. How would I create a many-to-many relationship between those objects? (if part one answered correctly) How could you ensure the relationship record was deleted if one of the records it was associated with was deleted?

4. A salesforce development best practice is to “Bulkify your trigger code”. Please explain that concept.

5. You have a set of account ids. Write an SOQL query to return the id, name, and email of all contacts who are associated with those accounts.

6. Explain the pros and cons of using Standard Visualforce rerendering vs Javascript Remoting.

7. You are working on a visualforce project that requires use of an external javascript library. How would you make the library available to your visualforce pages? 

Developing an app in my dev edition that processes email with an email service. Been working as intended, but everything stopped today. Tried testing several things and determined the email service is no longer processing email. Checked the debug log and emails aren't even hitting it. Out of curiousity I checked some other apps that use email services, and they aren't working either.

 

I've tried...

 

  • Ensuring that the sources of the emails have been added to the allowed addresses.
  • Manually sending emails to the service and checking the debug log.
  • Deactivating, then re-activating the service
  • Deleting the address, then creating a new one

Any ideas?

I'd like to poll my users on login. A chatter integrated would be awesome. Anyone else been down this path before?

 

So far, the best thing I've been able to come up with is a sidebar component that flashes when you have a poll to take.

Does anybody have any slick ways to accomplish this?

 

My current approach is to use the out of the box pagination with a custom list controller.  When someone clicks a column, it will modify the dynamic SOQL query behind the custom list controller to order by that column's field.

 

It's also important  for my sortable, paginating table to handle 1000+ records.

 

Thanks in advance.

Currently I have a trigger attached to when a new document is uploaded (after insert) in a custom document repository that I have created. When it is inserted, a new feed item is created and posted to the news feed as a linkpost item.

 

I was just wondering what would be the most efficent way of testing that this event has occured?

 

I've currently created a test class, created a 'test document' and inserted it to activate the trigger. I've then created a List<NewsFeed> newsfeed selecting the news feed. Then using System.assertEquals to compare the Title of the item on the top of the newsfeed to that of the test document I created. 

 

Is this the best way to test this?

 

I have encountered one problem doing this where the code executes too fast btween inserting the document and then getting the list so the System.assertEquals fails. To get round this I put in a while loop to waste a bit of time which seems to work now.

Hi ,

 

I haave a requirement when i populate 3 picklist hierarchical using code. Its working fine but i get duplicates.

 

Example :   xyz

                     xyz

                    abc

 

My code to populate one of the picklist is given below. This gets the elements from a field in the object and i get the value from it by iterating. My issue is i need to eliminate duplicates.

 

      public List<selectOption> getLanguageList() {
     
              List<selectOption> options = new List<selectOption>();
   
         for (List<NKJ_EmailTemp_Classify__c> listMapping : [select Language__c
                                                               from NKJ_EmailTemp_Classify__c 
                                                               where Certificate_Brand__c = :selectedBrand])
                                                            
          {
           for (NKJ_EmailTemp_Classify__c obj:  listMapping) {
               options.add(new selectOption(obj.Language__c, obj.Language__c));
           }
        
          }
            system.debug(options);
            return options ;             
      }

 

Note >> Blue are my custom objects where i select and in the innerloop i iterate over the fields to generate by options list.

  • March 09, 2011
  • Like
  • 0

When using InlineEditSupport with picklist fields - there is some odd behaviour occuring -

 

If the select dropdown happens to fall over another inlineEditSupport control [which almost always will be the case] - once you hover over an item in the dropdown that sits in front of another inlineEditControl - the select dropdown disappears.

 

In internet explorer (6-8 at least)

1. Have a pageBlock with 1 column and two fields that are dropdowns...

2. Initiate the inline edit and move the mouse over the select options down the page

3. When you end up at an option that sits in front of the second field - the select box disappears....

 

 

Ouch is this frustrating.

 

 

  • February 11, 2011
  • Like
  • 0

Can any one tel me how to write an trigger to insert the Opportunity lookup value in the custom object ,in which object is related list for  Opportunity.Thanks in advance reply me!!!!!!!

I have a VF Page called "bidPDFPreview" which I'd like to use as a "Preview PDF" page; it has an inline frame of a VF PDF called bidPDF. This all displays properly. I have a button that executes an APEX method to save the bidPDF as a QuoteDocument and redirect to the PDF. However, I am getting the following error upon executing my Save Method:

 

SObject row was retrieved via SOQL without querying the requested field: (fields on my bidPDF page)

 

 

My APEX Class is below, with the problem line of code bolded: (When I comment out that line, the button correctly just brings up the PDF). For simplicity's sake, I removed the code that actually creates the QuoteDocument from the Blob and inserts it since that is not what is causing this issue.

 

public class quoteExtension {

private final Quote qte;

public quoteExtension(ApexPages.StandardController stdController) {
this.qte = (Quote)stdController.getRecord();
}

public PageReference quoteSave(){

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id);
QuotePDFPage.setRedirect(true);
Blob QuotePDFBlob = QuotePDFPage.getContentAsPDF();
return QuotePDFPage;

}

}

 

Also note the bidPDF page is set to display as a PDF, and that Blob definition fails using both .getContentAsPDF() and .getContent()

 

When I add hidden fields onto my bidPDFPreview page, it seems to help (it starts showing errors for different fields), but it seems excessive to duplicate and hide all the code on my bidPDF page into the preview to make this work.

  • December 23, 2010
  • Like
  • 0

Hi All,

 

I am having real trouble with something very simple. I am trying to grab the account details of a contact from within the portal but can't seem to do it.

Any help would be much appreciated. This is my Apex Class so far.

 

public class communityUserObj {

    public Contact contact {get; private set;}

    public communityUserObj() {
        contact = [SELECT Id, Name, Email, AccountId, Account.Package__c from contact where contact.Id IN (select user.ContactId from user where user.id = :UserInfo.getUserID())];        
    }
  
}

  • December 23, 2010
  • Like
  • 0

Hi,

 

 

I am trying to display a message when checbox in my Visual force page is checked. I am using action support for my check box component. The re rendering part the section is working, but the set property of the checkbox  is not getting invoked i.e. I am not able to capture the checkbox value if its checked or unchecked.

 

Below is my source code. Thanks in advance

 

Controller

 

public Boolean specialInvest{

      get{

            if(specialInvest == null){

                  specialInvest = true;

            }

                       

            return specialInvest;  

      }

      set;

    }

 

 

Visual Force page

 

<apex:page standardController="Case" extensions="RMAEditPageController" action="{!pageLoad}">     
<script>


    var windowRef;
    var intervalId = 0;
    var globalObj;
    function openLookUpWindow(obj){
        //alert(obj);  
        var ele = document.getElementById(obj);
        var accId = document.getElementById("j_id0:rmaForm:block:RMASection:AccountNameItem:AccountName_lkid").value;
        //alert(accId);
        checkToOpenWindow(accId)
        //setTimeout(checkToOpenWindow, 2*1000);
    }
   
    function checkToOpenWindow(accountId){
        windowRef = window.open('/apex/lookUp?id='+accountId,'','width=500, height=300, scrollbars=yes, resizable=yes, menubar=no, status=no,toolbar=no');
        //checkWindowStatus();
    }
               
              
</script>
  <apex:form id="rmaForm" >
        <apex:pageMessages />
        <apex:pageBlock mode="edit" id="block" rendered="true" >
                <apex:pageBlockButtons location="both">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!saveAdd}" value="Save & Add or Mass Upload RMA Item"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
           
            <apex:pageBlockSection id="RMASection" title="RMA" columns="2" >
                <apex:pageBlockSectionItem id="AccountNameItem">
                    <apex:outputLabel for="AccountName">Account Name</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField required="true" id="AccountName" value="{!Case.AccountID}" />
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="ReturnTypeItem">
                    <apex:outputLabel for="ReturnType">Return Type</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField required="true" id="ReturnType" value="{!Case.Return_Type__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="ShipToItem">
                    <apex:outputLabel for="ShipTo">Ship To</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputText value="{!shipToNum}" id="ShipTo" onclick="javascript&colon;openLookUpWindow('{!$Component.RMASection}');" >
                        </apex:inputText>
                        <apex:commandButton reRender="ShipTo" action="{!lookUp}"  image="{!$Resource.lookupIcon}"  onclick="javascript&colon;openLookUpWindow('{!$Component.RMASection}');"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="InvoiceToItem">
                    <apex:outputLabel for="InvoiceTo">Invoice To</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="InvoiceTo"  value="{!Case.Invoice_To1__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
                               
                <apex:pageBlockSectionItem id="CustomerPOItem">
                    <apex:outputLabel for="CustomerPO">Customer PO</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="CustomerPO"  value="{!Case.Customer_PO__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="ContactNameItem">
                    <apex:outputLabel for="ContactName">Contact</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="ContactName"  value="{!Case.ContactID}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                 <apex:pageBlockSectionItem id="DescriptionItem">
                    <apex:outputLabel for="Description">Description</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="Description"   value="{!Case.Description}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
               
                <apex:pageBlockSectionItem id="SpecialInvestigationItem">
                    <apex:outputLabel for="SpecialInvestigation">Special Investigation</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputCheckbox id="SpecialInvestigation"   value="{!specialInvest}">
                            <apex:actionSupport event="onclick" reRender="note"/>
                        </apex:inputCheckBox>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

               
                 <apex:pageBlockSectionItem id="StatusItem">
                    <apex:outputLabel for="Status">Status</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:outputField id="Status"  value="{!Case.Status}" />
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

                </apex:pageBlockSection>
           
                           
                <apex:pageBlockSection title="Order Numbers" columns="2" id="OrderNumberSection">
                <apex:pageBlockSectionItem id="OrderNumberItem">
                    <apex:outputLabel for="OrderNumber">Order Number</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="OrderNumber"  value="{!Case.Original_Order_Number__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>

                 <apex:pageBlockSectionItem id="OrderLineNumberItem">
                    <apex:outputLabel for="OrderLineNumber">Order Line Number</apex:outputLabel>
                    <apex:panelGroup >
                        <apex:inputField id="OrderLineNumber"  value="{!Case.Original_Order_Line_Number__c}"/>
                    </apex:panelGroup>
                </apex:pageBlockSectionItem>
              </apex:pageBlockSection>
              </apex:pageBlock>
              <apex:pageBlock id="note">
                  <apex:pageMessages id="msg" rendered="{!specialInvest}"></apex:pageMessages>
              </apex:pageBlock>
          </apex:form>   
</apex:page>

 

 

 

  • December 23, 2010
  • Like
  • 0

Hi,

I have a before update and before insert trigger which for each records checks whether the record has modified its address and marks it as modified if yes.

The trigger works fine until a batch update of all records is performed in which case I get the following error:

 

System.LimitException: XXXX:Too many script statements: 12801

the question I have is how to either make the trigger to run in batch jobs but not throw that error OR how to disable the trigger in code (doing that manually is not an option) before the batch job is being run.

 

Thanks,

Kos

  • December 23, 2010
  • Like
  • 0

Hi,

 I want to upload existing user data with passwords into salesforce user object. I'm able to import user data but i neither find a way to upload a password directly nor the "Generate New Password" field in the User Object. How can i import or generate password through DataLoader?

 

I am creating a visualforce page and there is rable whihc needs to be rendered according to some condition I am writing the code as:

 

  <apex:outputPanel rendered="{!IF(ISEQUAL(Bil__c.Agent__c, Bill_c.Dealer__c},'true','false')}">

 

but its giving an error.

How do I check if a valid Contact is returned from a query like this in Apex.

 

Contact o = [SELECT c.Id, Email, LastName, FirstName, MailingCity, HomePhone, MailingState, MailingStreet, MailingPostalCode, AccountId, Source_Code__c, Drupal_User_Id__c FROM Contact c WHERE c.Email = :n.Email AND c.Id != :n.Id limit 1];

 

How do I check to see if o is a populate Contact object.

I have two VisualForce page that use the standard controller. They are essentially identical to each other, except that one has output fields and one has input fields. Right now, I override View and Edit with the appropriate VisualForce page.

 

Is there any way to embed a VisualForce page onto a standard layout and have it be available for viewing and for editing? I tried embedding a VisualForce page onto the standard layout. It displays fine in view mode, but when I click the Edit button, I can only edit the fields on the standard layout. The VisualForce page disappears entirely. The other half of this question would be how to accomplish this given the available options of apex:outputField and apex:inputField. It seems that this does't lend a single VisualForce page to both viewing and editing.

  • December 22, 2010
  • Like
  • 0
I want to create a resuable custom component for multi select picklist type in visualforce.

Hi,

 

I am calling a controller function using apex:commandlink

 

<apex:commandLink action="{!Next}" rendered="true" reRender="CustomList">{!showNext}</apex:commandLink>

 

When using Firefox browser function call is working properly, but with IE control again goes to <init> and next() function is not called.

 

Also, the viewstate is not maintained when using IE. Crippled around this for many days,  can somebody please advice.

 

Thank in advance.

 

Aditya