• Ken_Koellner
  • NEWBIE
  • 185 Points
  • Member since 2009

  • Chatter
    Feed
  • 7
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 115
    Questions
  • 99
    Replies

I was just curious at what point of developing your Trigger, do you decide to move your code to a Class instead?  My Trigger keeps getting larger, but because I need to iterate through the Trigger.new, I haven't wanted to move everything out to a Class - but now I'm wondering if it would make life easier (though harder at first...)?

  • November 15, 2010
  • Like
  • 0

I have a special form, in which there are no inputfield, only a table with radio buttons, I actually set the field value based on the radio button selected. (See image)

 

 

So if leave the InputField box (see top row), then the context is kept and I can save, however, If they are not included the context is not kept and saving saves the old values.

 

 

public myCriteriaScorecardExtension(ApexPages.StandardController controller)
{
baseController = controller;
scorecard = (Criteria_Scorecard__c) baseController.getRecord();
...

 

 including this is the only way the context is kept, if I hide them with rendered="false" it stop working, if I use outputfield instead of inputfield, it also stop working.

<apex:pageblock mode="edit" id="PB1">
<apex:inputField value="{!scorecard.Question1__c}" rendered="true" />
<apex:inputField value="{!scorecard.Question2__c}" rendered="true"/>
<apex:inputField value="{!scorecard.Question3__c}" rendered="true"/>
<apex:inputField value="{!scorecard.Question4__c}" rendered="true"/>
<apex:inputField value="{!scorecard.Question5__c}" rendered="true"/>
<apex:inputField value="{!scorecard.Question6__c}" rendered="true"/>
</apex:pageblock>

 

 

 

 

Message Edited by BrokenBird on 05-23-2009 11:15 AM
Message Edited by BrokenBird on 05-23-2009 11:16 AM

The commandLink button coded below works fine.  It passes the value from entry.tempLineId to merge variable buttonOppLineTempId.  I consider this a work-around.  It is a link that looks like a button.

 

Below the link a commandButton.  This does not work.  I do not get the merge variable set.

 

Anyone know how param is supposed to work with commandButton.  The VF doc says param can be inside commandButton but give no information on how it behaves in this situation.

 

                    <apex:commandLink styleClass="btn" style="text-decoration:none;" id="oppLineLink" value="Take CP Lines" action="{!takeCpLines}" rendered="{!entry.isOppLine}">
 	                    <apex:param id="buttonParam" name="tempLineId" value="{!entry.tempLineId}" assignTo="{!buttonOppLineTempId}"/>
                    </apex:commandLink>  
                    <apex:commandButton id="oppLineButton" value="Take CP Lines" action="{!takeCpLines}" rendered="{!entry.isOppLine}">
 	                    <apex:param id="linkParam" name="tempLineId" value="{!entry.tempLineId}" assignTo="{!buttonOppLineTempId}"/>
                    </apex:commandButton>  

 

I want a button in my page block table that calls an action method with a row number as a paramenter.  Anyone know if there's a way to refer to the row number?

  <apex:column id="myColumn">
	<apex:commandButton value="MyButtonLabel">
		<apex:param name="rowNumber" value="???"/>
	</apex:commandButton>
  </apex:column>

Assuming that column is within a PageBlockTable What I'd like to do is put something in the ??? in the code segment above that will give me the row number, 0-n.

 

 

I have some field-dependent picklists defined in a custom object.

 

Does anyone know know if <apex:inputfield> will honor those picklist field dependencies?


In more detail, suppose I have FieldA and FieldB in a custom object.  The picklist values for FieldB depend on FieldA.  Both FieldA and FieldB are on a VF page.  If the user sets the value of FieldA, will the available picklist values for FieldB change?

 

I could have swore I prototyped this a few weeks ago and it worked.  Now it is not working on my page.

 

I do have the inputfield in a PageBlockTable.  Could it work for scaler fields but not in tables?

I guess this is more a rant than a question.

 

Do this--

 

List<Integer> myList = new list<Integer>();
...
myList.add(0,86);

 

And your program faults with an index out of bounds exception.

 

That forces you to code --

 

List<Integer> myList = new list<Integer>();
...
if (myList.size() == 0) { myList.add(86); } else { myList.add(0,86); }

 

It would be nice if you add(0,newElement) just added the element to the beginning of the list regardless of whether it had any members yet.

 

Java documentation on list.add() says -- IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())

 

So in Java index == size() would be legal. 

 

Why didn't they just to that in Apex?

 

 



I need to run a query selecting some fields from OpportunityLineItem, PricebookEntry, and Product2.  That's a simple inner join.  I can do the query in Apex Explorer but it's impractical to get 250K rows out.

 

Anyone know a better query tool for doing larger queries to flat files?

 

 

We have a large VF page that is essentially all Javascript.  It has a huge complex grid with expanding trees and such.  There is are a client of client-side actions processed.  Currently it is uses extjs (a big Javascript library).  Even though it's a VF page, it is essentially all Javascript using the data API to read and write data from SF.

 

We're considering partially or completely rewritting it.  The implementation is cumbersome to maintain and it also doesn't work with mobile devices like iPads and Android tablets.

 

I doubt we could ever do everything in the page in native VF.

 

I'm looking for suggestions for additional technologies we might use to re-write the page better.

 

I don't know enough about HTML5 yet to know if it can do it.  Anyone care to comment?

 

Anyone have any other ideas for what to consider?

 

Anyone recall what debugging facility and where to inspec the view state?

 

I think it's in Apex CSI (new system log) somewhere but I forget where.

 

 

Documenation says -- Apex allows developers to lock sObject records while they are being updated in order to prevent race conditions and other thread safety problems. While an sObject record is locked, no other program or user is allowed to make updates.

 

Is this how it would work--

 

Scenerio 1:

 

Thread A reads with FOR UPDATE.

Thread B reads with FOR UPDATE, read succeeds as lock only blocks the update DML.

Thread A tries to update but fails with an Exception as thread B has a lock.

Thread B tries to update and it works because the thread A no longer has lock.

 

Scenerio 2:

 

Thread A reads with FOR UPDATE.

Thread B reads with FOR UPDATE, read succeeds has lock only blocks the update DML.

Thread B tries to update but fails with an Exception as thread A has a lock.

Thread A tries to update and it works because the thread B no longer has lock.

 

 

 

SF now supporse Field Dependencies in pick list values.  So the available list of pick list values can be driven by what's selected in another pick list field.

 

Do you konw if that is honored in the apex:inputField with an sObject in VF?

 

In other words, if I put both pick list fields on the page with apex:inputField, will the available values of the 2nd pick list be driven the first pick list assume the dependencies defined that way?

 

 

 

A follow up question also, sometimes, you need to use an hand-coded drop down that isn't an inputField as  you want the same list of values for a field that isn't in an sObject.  I know you can query metadata to get the list off picklist values for a field.  Can you query the metadata and get the information about the Field Dependicies also?

 

The documentation on Apex.Pages.Message lists the five severity levels but it doesn't say a word about whether they do anything special in the processing.

 

Like what does "CONFIRM" do?  Does it just put up a message is does it engage in some sort of confirmation dialog automatically?

 

I'm using a custom controller so the stuff on standard controllers doesn't apply.

 

I read through some of the documentation on setting up SF-to-SF connection but I can't find anything on how permissions are applied when you subscribe and specify auto-accept.  Under what user/profile is the record in your org updated?  Is it even a regular profile?  Does it run under the profile of the user that set up the auto-accept?

I have a real small sites app that was written in VF by another developer.

The controller uses Apex Messaging.sendEmail to send an email. The from email address is coming from a specific user's email address as if  the sendng user is hard-coded somewhere but I don't know where.  it's not in the Apex code.

 

The  setSenderDisplayName() and setReplyTo() methods are used to set those options and they come out okay.  But the actual from address isn't/can't be set with method calls.  The documentation says it comes from the current user.  I'm not sure what the user would be in the context of a Sites app.  I checked the Site Contact on the site configuration and changed it but that's not it.

 

So this email is still being sent from some hard-coded User's address.  I can't find it anywhere.

 

Any clue where it might be coming from?

 

The UNABLE_TO_LOCK_ROW which can make debugging almost impossible in a complex application.  I don't know if this is intentional or not but it seems to me that if the server detects deadlock (or timeout), it knows the record ID and could just as easily put it in the message.

 

If you know a way to get the ID, I would be call to let me know.

 

If there is no way to get the ID, vote for the idea on Ideas--

 

https://sites.secure.force.com/success/search?type=Idea&keywords=UNABLE_TO_LOCK_ROW: https://sites.secure.force.com/success/search?type=Idea&keywords=UNABLE_TO_LOCK_ROW

 

 

Is there any limit to the number of entries in a set or list that can be used in an IN clause in SOQL?

 

 

List<Id>myIdList = ....

List<OpportunityLineItem>oliList = [select id, opportunityId, quantity
                                    from OpportunityLineItem
                                    where id in :myIdList];

 

Is there anythg that would prevent myIdList having 100, or 1000, or 5000 entries and still working with the SOQL query?

 

I writing a page that lets a user submit a certain batch apex task.  I want to get the exception where the limit of 5 queued/running jobs is exceeded so I can put up a message tell the user to try again later.

 

I tried running the sample code below as ad-hoc apex to test the catch.  It compiles but the exception is not caught.  Am I not catching the correct Exception?

 

 

KenTestBatchable ktb ;

for (integer i=0; i<7; i++) {
  try {
    ktb = new KenTestBatchable('1000');
    Database.executeBatch(ktb);
  } catch(LimitException ex) {
	system.debug ('xyzzy ' + ex.getMessage());
  }
}

 

 

I'd like to be able to set defaults when a user hits the "New" button on a custom object based on some simple logic.

 

Like set a value to a lookup from their User record?

 

Is there any way to do this or can defaults only be hard-coded values?

 

I guess the alternative would be to override the New button with some VF code but that's a heck of a lot of work to initialize a few fields.

 

It looks to me that if you have a Date or Datetime field in an sObject and uses InputField, you get a nice Data or Datetime selector feature when the page renders.

 

What about if you just have a Date, Datetime, or Time values in Apex merge variables that are not sObjects and want to do input without directly connecting to an sObject field?

 

Is there no way to get access to the same date, and datetime selector on the page?

 

It would also be nice if there were a Time entry feature that works like Time does on the Event page layout.

 

There's nothing like that built into VF?

 

 

Anyone know if rolled back updates count toward the DML limit?

 

There limit on DML rows is 10,000.


Support I update 8,000, do a rollback, then update 5,000 more.  Will the blow the limit?

 

 

I have CustomObjectA and Opportunity.  I added a lookup relationship in Opportunity to CustomObjectA and an Opportunity page layout then gets a related list of CustomObjectA.

 

What I to happen is the user visits a record in CustomObjectA and therefore it gets on their most-recent list.

 

Then, the user user goes into Opportunity and edits a record.  They go to add a CustomObjectA to the related list on Opportunity and therefore get into the Search facility.  What I want to happen is that the recently visited CustomObjectA appears first by default.

 

Is there any way to set up a search layout, or any other mechanism, where by it will be easy to find the most recently visited records when adding to a related list?

 

 

A need to create a Datetime value in a given user's timezone.  There are method for the current user and methods for GMT but no method for the current user.

 

Anyone know of a convenient way to do this.  I can get there timezone from the user record.  It will be a string like "America/New_York".  I supposed a could build a table with all the offsets, look up the offset, then construct a datetime in GMT and add the appropriate number of hours.

 

Anyone know of a better way to do this?

 

-Ken

 

Is there any limit to the number of entries in a set or list that can be used in an IN clause in SOQL?

 

 

List<Id>myIdList = ....

List<OpportunityLineItem>oliList = [select id, opportunityId, quantity
                                    from OpportunityLineItem
                                    where id in :myIdList];

 

Is there anythg that would prevent myIdList having 100, or 1000, or 5000 entries and still working with the SOQL query?

 

 

A client of one of our web service written in Apex reported an error.  It turns out there was an error --

 

Insert failed. First exception on row 9; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusie access to this record: []

 

I'm trying to think of what would cause an lock problem on an insert.  The method does to a start transaction and then inserts a row in Opportunity and then several in OpportunityLineItem. 

 

I don't see how the problem could be with the row being inserted.  Could it be with something locked a parent record like account?  Could something have already read the Opportunity record while the OpportunityLineItem records where being written?

 

I want a button in my page block table that calls an action method with a row number as a paramenter.  Anyone know if there's a way to refer to the row number?

  <apex:column id="myColumn">
	<apex:commandButton value="MyButtonLabel">
		<apex:param name="rowNumber" value="???"/>
	</apex:commandButton>
  </apex:column>

Assuming that column is within a PageBlockTable What I'd like to do is put something in the ??? in the code segment above that will give me the row number, 0-n.

 

 

I have some field-dependent picklists defined in a custom object.

 

Does anyone know know if <apex:inputfield> will honor those picklist field dependencies?


In more detail, suppose I have FieldA and FieldB in a custom object.  The picklist values for FieldB depend on FieldA.  Both FieldA and FieldB are on a VF page.  If the user sets the value of FieldA, will the available picklist values for FieldB change?

 

I could have swore I prototyped this a few weeks ago and it worked.  Now it is not working on my page.

 

I do have the inputfield in a PageBlockTable.  Could it work for scaler fields but not in tables?

I guess this is more a rant than a question.

 

Do this--

 

List<Integer> myList = new list<Integer>();
...
myList.add(0,86);

 

And your program faults with an index out of bounds exception.

 

That forces you to code --

 

List<Integer> myList = new list<Integer>();
...
if (myList.size() == 0) { myList.add(86); } else { myList.add(0,86); }

 

It would be nice if you add(0,newElement) just added the element to the beginning of the list regardless of whether it had any members yet.

 

Java documentation on list.add() says -- IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())

 

So in Java index == size() would be legal. 

 

Why didn't they just to that in Apex?

 

 



Anyone recall what debugging facility and where to inspec the view state?

 

I think it's in Apex CSI (new system log) somewhere but I forget where.

 

 

Documenation says -- Apex allows developers to lock sObject records while they are being updated in order to prevent race conditions and other thread safety problems. While an sObject record is locked, no other program or user is allowed to make updates.

 

Is this how it would work--

 

Scenerio 1:

 

Thread A reads with FOR UPDATE.

Thread B reads with FOR UPDATE, read succeeds as lock only blocks the update DML.

Thread A tries to update but fails with an Exception as thread B has a lock.

Thread B tries to update and it works because the thread A no longer has lock.

 

Scenerio 2:

 

Thread A reads with FOR UPDATE.

Thread B reads with FOR UPDATE, read succeeds has lock only blocks the update DML.

Thread B tries to update but fails with an Exception as thread A has a lock.

Thread A tries to update and it works because the thread B no longer has lock.

 

 

 

I read through some of the documentation on setting up SF-to-SF connection but I can't find anything on how permissions are applied when you subscribe and specify auto-accept.  Under what user/profile is the record in your org updated?  Is it even a regular profile?  Does it run under the profile of the user that set up the auto-accept?

I writing a page that lets a user submit a certain batch apex task.  I want to get the exception where the limit of 5 queued/running jobs is exceeded so I can put up a message tell the user to try again later.

 

I tried running the sample code below as ad-hoc apex to test the catch.  It compiles but the exception is not caught.  Am I not catching the correct Exception?

 

 

KenTestBatchable ktb ;

for (integer i=0; i<7; i++) {
  try {
    ktb = new KenTestBatchable('1000');
    Database.executeBatch(ktb);
  } catch(LimitException ex) {
	system.debug ('xyzzy ' + ex.getMessage());
  }
}

 

 

It looks to me that if you have a Date or Datetime field in an sObject and uses InputField, you get a nice Data or Datetime selector feature when the page renders.

 

What about if you just have a Date, Datetime, or Time values in Apex merge variables that are not sObjects and want to do input without directly connecting to an sObject field?

 

Is there no way to get access to the same date, and datetime selector on the page?

 

It would also be nice if there were a Time entry feature that works like Time does on the Event page layout.

 

There's nothing like that built into VF?

 

 

Anyone know if rolled back updates count toward the DML limit?

 

There limit on DML rows is 10,000.


Support I update 8,000, do a rollback, then update 5,000 more.  Will the blow the limit?

 

 

I always thought GMT aka UTC aka Z was absolute and never used Daylight Saving Time.  I ran the ad-hoc apex below.  I'm in Boston and we are now in Daylight Savings Time my timezone.  In my User record page, my timezone shows as "(GMT-05:00) Eastern Daylight Time (America/New_York)".  Now that seems to me to be weird is EDT is GMT-4:00 and EST is GMT-5:00 unless Salesforce considers GMT as having daylight savings time.

 

I ran the ad-hoc Apex below to test th difference between my time and GMT and it is indeed 5.

 

So, does SF move GMT to Day Light Savings time?  Does it do it on the same date as the USA moves to Daylight Savings Time?

 

 

User currentUser = [select Email,TimeZoneSidKey From User where Id=: userInfo.getUserId()];
 
Datetime myDateTimeLocal = DateTime.newInstance(1970,1,1);
Datetime myDateTimeGMT = DateTime.newInstanceGMT(1970,1,1);

Long myLongLocal = myDateTimeLocal.getTime();
Long myLongGMT = myDateTimeGMT.getTime();

Long hoursDiff = (myLongLocal - myLongGMT) / 60 / 60 / 1000;

System.debug ('xyzzy Diff  ' + hoursDiff);
System.debug ('xyzzy Local ' + myDateTimeLocal);
System.debug ('xyzzy GMT   ' + myDateTimeGMT);
System.debug ('xyzzy TZ    ' + currentUser.TimeZoneSidKey);


 

 

I want to compose an email body in Apex code and include a link in it.  The link can be "/" plus the ID of the object but the URL needs to be construction relative to the current instance.  I can't code "http://na2.salesforce.com/..." as it might not work.  Also, it should work with the proper URL for each sandbox.

 

Anyone know a way in Apex to get the root URL for the current environment?

 

I don't think VF email templates will work in my case.

I'm creating Events with a specify record type programmatically and assigning them to various users.

 

I don't want the users who own these types of events from editing or deleting them.

 

I'm trying to think of the best way to prevent it.  I can take the Edit and Delete button off the layout but there is still an Edit and Delete button on the mini-layout and in the related list.

 

I figure with a validation, I can at least prevent edit of three or four critical fields and that's what I most care about so that is a reasonable solution.  I likely want to at least allow the user to dismiss the event so I have to let them modify a few fields any way.

 

I have no idea if there is a way with validation to prevent delete.  Any suggestions?

 

 

Any other ideas?

I think this is do-able.  I just want to make sure.

 

I remember an example from the VF class of a wizard for job applications that let you do Next/Prev over three pages.  I think the way it worked is that it used the same instance of the controller for all pages.

 

I want to double-check that that is do-able.  I have a constructor that gets a great deal of data and holds it in memory.  I want to go to/from a detail page without reinstantiating the controller.  If it reinstantiates the controller, it would be too inefficient.  If it can't be done, then I'd do it by using the same page and having sections rendered based on where the user is.  It would be more elegrant to use separate pages though.

 

-Ken

 

Anyone know exactly what that message means and how things are counted?  There's nothing stated as an "id limit" in the table of limits in the Apex manual.

 

 

 

Select o.Id, o.Line_Item_Status__c, o.OpportunityId, 
o.Opportunity.AccountId, 
o.Opportunity.Account.parentId, 
o.Opportunity.Account.parent.parentId, 
o.Opportunity.Transaction_Type__c from OpportunityLineItem o  where o.Line_Item_Status__c = 'Shipped'
and o.Opportunity.transaction_type__c = 'xyzzy'

 

 

I limited added a limit 9999 on the end of that and still hit the limit.  I'm wondering if the 10,000 limit is not just on the primary table of the query, OpportunityLineItem, but on all the tables.  Thus each row visited in OpportunityLineItem, Opportunity, and Account added up must be not greater > 10,000. 


Is that how the limit works?

 

I know many of the limits in Apex have either been raised or removed.  But "For loop list batch size" is still listed as 200.

 

Anyone know exactly what the limit is?  It isn't clearly defined anywhere . 

 

It seems to me I've had lists > 200 processed in a for lopp.  Also, I don't think you need the nested for loop when fetching > 200 items from a SOQL query any more.

 

So, what is it?

 

I know a callout to a web service from Apex is limited to a responsde size of 1MB.

 

Is there any limit on the size of input to a web service implemented in Web Service?

 

I don't see anything clearly listed in the documentation but sometimes things aren't where'd you'd expect to find them.