• David Wright
  • NEWBIE
  • 75 Points
  • Member since 2011
  • Software Application Developer
  • Siemens

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

Hello!

I'm looking to create a trigger that will populate a picklist field from the asset name. Like If asset name starts with X, then set value Y. I tried with field updates but it won't fire until i save the record, and i need it to fire at the creation of the record (when i click on ''new case'')

the reason why i need a picklist auto populated is because i need it to control another picklist, and it won't work with a formula field.

can anyone help?

thanks!

I have to get all the orders printed in pdf format. Each order has some related order line items. i have used <apex:repeat value="{!order}" var="ord"> for the order loop. Now from the loop how can i get the related child Order_line record's values. I cannot use related list as it will give all values of the records, but i want some of its values.

 

Thanks in advance

I'm having trouble understanding what the global keyword actually does does in Apex. I know what the docs say, so I'm not looking for anyone to spit that out. The docs say:

"The global access modifier declares that this class is known by all Apex code everywhere. All classes that contain methods defined with the webService keyword must be declared as global. If a method or inner class is declared as global, the outer, top-level class must also be defined as global."

The phrase "...known by all Apex code everywhere." is confusing to me, and possibly even a little scary. Is it suggesting that using the global keyword allows your code to be visible across other orgs (literally ALL apex code, at least for that SFDC instance), or is it just visible to all apex in your org, and if so, how is that different from simply using the public keyword?

Force.com developer/admin needed for a full time position near Raleigh, NC. 

 

This position will act as a process and application developer working with the business internally, learning business processes and developing force.com apps to support those processes. Get to work with some awesome people and break new ground on huge process development improvements!

 

Note that we are looking for an FTE, not a consulting partner. If you're interested, please send me a private message and I'll be happy to give you more details.

 

Note: I'm not an HR recruiter, I'm a fellow developer looking for a great colleague to work with!

Force.com developer/admin needed for a full time position near Raleigh, NC. 

 

This position will act as a process and application developer working with the business internally, learning business processes and developing force.com apps to support those processes. Get to work with some awesome people and break new ground on huge process development improvements!

 

Note that we are looking for an FTE, not a consulting partner.

I'm trying to implement a mobile Visualforce page that allows a user to draw a picture (using HTML Canvas), obtain the canvas as an image using the canvas.toDataURL() method, and save that image back to Salesforce as an attachment.

 

I've attempted to pass the toDataURL() result back to the controller using an actionfunction with a parameter, however when the following code runs, I'm receiving the message "Argument 1 cannot be null", so the result of toDataURL() isn't getting passed to the action function for some reason. Can anyone comment on why they think that's happening, or offer an alternative to accomplsih what I'm trying to do?

 

    <apex:form >
        <apex:inputHidden id="theImg" value="{!img}" />
        <div id="container" > 
            <canvas id="sketchpad" width="766" height="600"> 
                Sorry, your browser is not supported.
            </canvas>     
        </div>           
        <div id="not_container" style="border:2px solid #AAA;margin-top:25px;width:766px;height:100px;">
          <input type="button" value="Save Image" style="height:100%;width:25%" onclick="saveImage();"/>
          <script type="text/javascript">
              function saveImage() {
                  var canvas = document.getElementById("sketchpad").toDataURL("img/jpg");
                  submitToController(canvas);
              }
          </script>
          <apex:actionFunction name="submitToController" action="{!saveImage}">
              <apex:param name="myImg" value="" />
          </apex:actionFunction>
        </div>
    </apex:form>

 

I'm attempting to implement the cookie class in order to store field values from a form on a Sites page. I'm wondering if anybody has done this, because I seem to be confused at how the cookie class works.

 

According to the documentation, cookies can only be created and set in the constructor of the page controller, but no form values are known when the constructor is executed! The limitations this create are pretty substantial--unless I'm understanding it incorrectly. The way I understand it, you can only store values in cookies that are known at the time of page load, which isn't very much... at least not for a page where a user is entering a bunch of data on a form.

 

If anyone has any experience with this, please share...

I have a trigger that runs on updated (converted) leads, so I need to be able to emulate that process in my Apex test class in order to test correctly. I've followed the documentation as instructed Here, but I'm getting an error during test execution that I'm not sure how to fix.

/*
* Test class for the TransferIndustryContacts trigger 
*/
public with sharing class Test_TransferIndustryContacts {

	//Declare test method
	public static testmethod void doTest() {
		
		//Create a new lead that will be converted into a new account and contact
		Lead newLead = new Lead(lastname = 'Test1_Lname', company='Test1_Acct');
		insert newLead;
		
		//Create the LeadConvert object
		Database.LeadConvert lc = new database.LeadConvert();
		
		//Set the newly inserted lead as the target to this LeadConvert
		lc.setLeadId(newLead.id);
		
		//Set the required ConvertedStatus field
		LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted = true limit 1];
		lc.setConvertedStatus(convertStatus.MasterLabel);
		
		//execute lead conversion
		Database.LeadConvertResult lcr = Database.convertLead(lc);
		
		//Confirm that the new contact belongs to the correct account
		//as assigned by the trigger (Account ID = 00100000005Q96h)
		Contact newContact = [SELECT Id, AccountId FROM Contact WHERE Id = :lcr.getContactId()];
		System.assert(newContact.AccountId == '00100000005Q96h');
	}

}

 The error occurs on the line that performs the database.convertLead() method, but the error it throws is:

 

"INVALID_STATUS, invalid convertedStatus: Qualified --> Account: []"

 

I know "Qualified --> Account"  is what is getting returned by the query to LeadStatus, but the option is a valid for the converted status during the lead conversion in the UI. I also tried hard coding in another option from this list to no avail. Any suggestions?

 

 

I'm having trouble understanding what the global keyword actually does does in Apex. I know what the docs say, so I'm not looking for anyone to spit that out. The docs say:

"The global access modifier declares that this class is known by all Apex code everywhere. All classes that contain methods defined with the webService keyword must be declared as global. If a method or inner class is declared as global, the outer, top-level class must also be defined as global."

The phrase "...known by all Apex code everywhere." is confusing to me, and possibly even a little scary. Is it suggesting that using the global keyword allows your code to be visible across other orgs (literally ALL apex code, at least for that SFDC instance), or is it just visible to all apex in your org, and if so, how is that different from simply using the public keyword?
I'm having trouble understanding what the global keyword actually does does in Apex. I know what the docs say, so I'm not looking for anyone to spit that out. The docs say:

"The global access modifier declares that this class is known by all Apex code everywhere. All classes that contain methods defined with the webService keyword must be declared as global. If a method or inner class is declared as global, the outer, top-level class must also be defined as global."

The phrase "...known by all Apex code everywhere." is confusing to me, and possibly even a little scary. Is it suggesting that using the global keyword allows your code to be visible across other orgs (literally ALL apex code, at least for that SFDC instance), or is it just visible to all apex in your org, and if so, how is that different from simply using the public keyword?

I have built a custom report using Visual Force. I am trying to give the end user the ability to sort the report by a few different fields. I have created a pick list on a Custom Object that contains the field names (API Names) that the user can sort by. In my class I query the Custom object to get the field the end user wants to sort by, I store that in a variable. I then want to use that vairble to order by my SOQL statement that builds the report.

 

Here is my Query to build the report:

 

String shipping = '%Small Parcel%';
String Stage = 'Closed Won';

String Query = 'SELECT Estimated_Ship_Date__c, Date_Shipped__c, Opportunity.CloseDate, Opportunity.Account.Name, From OpportunityLineItem WHERE Opportunity.StageName = :Stage and (NOT ShippingType__c like :shipping) ORDER BY ';
Query += SortBy ;

List<OpportunityLineItem> myOCR = Database.query(Query);

return myOCR;

 

When I hard code the SortBy Variable the query works perfectly however I need to set the SortBy varible to the result of another query and I cannot get the correct syntax. Here is what I have tried so far and none of these worked:

 

String SortBy = 'Select SortBy__C from Custom__c Where Name = FreightDashboard' ;

 

String SortBy = '(Select SortBy__C from Custom__c Where Name = FreightDashboard)' ;

 

String sortx = 'Select SortBy__C from Custom__c Where Name = FreightDashboard' ;
List<Custom__c> Sortby = Database.query(sortx);
Return Sortby;

 

list<Custom__c> Sortby;
list <Custom__c> customa = ([Select SortBy__C from Custom__c Where Name = 'FreightDashboard']);{
   for (Custom__c cx:customa){
   Sortby.add(cx.SortBy__C); //not sure on this syntax 
  }
}

 

 

list<Custom__c> Sortby;

  public list<Custom__c> getCustom__c() {

        Sortby = ([Select SortBy__C from Custom__c Where Name = 'FreightDashboard']);

        return Sortby;
}

 

 

As you can probably tell I am new to SOQL. I have experience with SQL but I am struggling with this Order by variable.

 

Thank you,

 

Hello!

I'm looking to create a trigger that will populate a picklist field from the asset name. Like If asset name starts with X, then set value Y. I tried with field updates but it won't fire until i save the record, and i need it to fire at the creation of the record (when i click on ''new case'')

the reason why i need a picklist auto populated is because i need it to control another picklist, and it won't work with a formula field.

can anyone help?

thanks!

I'm trying to implement a mobile Visualforce page that allows a user to draw a picture (using HTML Canvas), obtain the canvas as an image using the canvas.toDataURL() method, and save that image back to Salesforce as an attachment.

 

I've attempted to pass the toDataURL() result back to the controller using an actionfunction with a parameter, however when the following code runs, I'm receiving the message "Argument 1 cannot be null", so the result of toDataURL() isn't getting passed to the action function for some reason. Can anyone comment on why they think that's happening, or offer an alternative to accomplsih what I'm trying to do?

 

    <apex:form >
        <apex:inputHidden id="theImg" value="{!img}" />
        <div id="container" > 
            <canvas id="sketchpad" width="766" height="600"> 
                Sorry, your browser is not supported.
            </canvas>     
        </div>           
        <div id="not_container" style="border:2px solid #AAA;margin-top:25px;width:766px;height:100px;">
          <input type="button" value="Save Image" style="height:100%;width:25%" onclick="saveImage();"/>
          <script type="text/javascript">
              function saveImage() {
                  var canvas = document.getElementById("sketchpad").toDataURL("img/jpg");
                  submitToController(canvas);
              }
          </script>
          <apex:actionFunction name="submitToController" action="{!saveImage}">
              <apex:param name="myImg" value="" />
          </apex:actionFunction>
        </div>
    </apex:form>

 

Hi,

 

   I have List Collection type on one object. Now, i want to print those values of object one by one on a visual force page.

 

   how, could i place record by record (say.,

 

     1st record

 

     2nd record

 

     3rd record..........)

 

     Thanks in advance........

 

  • September 19, 2011
  • Like
  • 0

I'm attempting to implement the cookie class in order to store field values from a form on a Sites page. I'm wondering if anybody has done this, because I seem to be confused at how the cookie class works.

 

According to the documentation, cookies can only be created and set in the constructor of the page controller, but no form values are known when the constructor is executed! The limitations this create are pretty substantial--unless I'm understanding it incorrectly. The way I understand it, you can only store values in cookies that are known at the time of page load, which isn't very much... at least not for a page where a user is entering a bunch of data on a form.

 

If anyone has any experience with this, please share...

I have to get all the orders printed in pdf format. Each order has some related order line items. i have used <apex:repeat value="{!order}" var="ord"> for the order loop. Now from the loop how can i get the related child Order_line record's values. I cannot use related list as it will give all values of the records, but i want some of its values.

 

Thanks in advance