function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
colemabcolemab 

CommandLink shows status but debug log doesn't show method being called?

Everyone,

 

A month ago, I opened a ticket with SFDC support for inconsistent behavior with command links in pageblocktables.   They have confirmed the issue but still don't have a resolution.

 

So, I was wondering if this effected anyone else.    Anyone else seen a command link fail to call a method in some situations but call that same method just fine in other siutations on the same page?

 

I want to clarify that the command link code is the same in the VF page as it is in a page block table.  However, some times individual rows in the table call the command link upon click but others do not.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
colemabcolemab

Everyone,

 

I have ran down the issue with help from SFDC.   The command link was part of a pageblocktable that is populated from a list.

 

The list was getting changed on the first click but the pageblocktable that displays this list wasn't being rerendered.   So the element that had the non-working command link wasn't in the list.  

 

Since it was in the database, I expected to see a call to the method and the code execute.  However, salesforce says that the view state is the link between the method being called and the java script event.  Since the viewstate was updated when the list was updated, the viewstate copy of the list didn't have that entry and thus the call failed but nothing was in the log.

 

Salesforce said they are considering making a log entry for debugging when this happens and they are also considering listing this scenario under the documentation / best practices.

 

FYI & Thanks

All Answers

bob_buzzardbob_buzzard

Only when I've been hitting an error and not displaying it back on the page, so effectively the method call fails silently.

colemabcolemab

Bob,  thanks for the reply.   What kind(s) of errors have you been hitting?  I ask because if I can identify any errors and work around them on my end, that would probably be best at this point as I could continue with the project.

 

In my method, the first line is a system.debug message.   Since this never appears in the logs (even with max levels set), the method is not getting called as far as I can tell. 

 

Since the method is being called from a command link on a VF page (as opposed to apex code), I am not sure what kind of errors I would have control over.

 

I saw an old post in this forum from 08 or 09 where someone reported a similar problem but I never saw a solution.

 

Thanks

bob_buzzardbob_buzzard

I've seen this where there have been required fields elsewhere, but the commandlink was only rerendering a different section of the page.  There was an error occurring, but as the affected fields weren't rerendered, it took us a while to figure out what was happening, as the page simply refreshed without saving the changes.

 

Once we added an apex:pagemessages component and made sure we rerendered that in all cases, it flagged up the error straight away.  I vaguely recall seeing something similar involving custom validation rules, but I couldn't say for sure that it was the same problem and solution.

colemabcolemab

That was a good thought.  I had the apex messages on the page but not in a section that was always being re-rendered.  This is because the VF page in question isn't really for data entry but mainly viewing.  

 

Anyway, I have made the apex messages always re-render and it didn't solve the issue.  Thanks again for sharing your experience - I will always re-render my apex messages section now.

 

In my case I have a search box that runs an SOSL search and then displays the results in a pageblocktable.   The first column of that table has a command link that calls a method to use the id to show the details of the clicked entry below.   However, the command link doesn't always call the method.   In some cases only links 1 & 2 work and 3-N fail and in some other cases none of the links work.   However, the status image is displayed as if the call is made but the logs don't show the method being called.   Crazyness.

 

 

bob_buzzardbob_buzzard

Very strange. I'm doing something similar in a couple of places and I haven't come across this type of behaviour.  If anything else comes to mind I'll post back here.

colemabcolemab

Salesforce support has responded and indicated that the problem is due to having mutiiple forms on the page.  They also mention that the documentation indicates a best practice of having at most 1 form per page.

 

I will refactor my page to have just one form and post the results here but just an FYI for others in the mean time.

colemabcolemab

For those that care, refactoring down to 1 form didn't solve the problem and support is still reviewing the issue.  Just FYI

colemabcolemab

Everyone,

 

I have ran down the issue with help from SFDC.   The command link was part of a pageblocktable that is populated from a list.

 

The list was getting changed on the first click but the pageblocktable that displays this list wasn't being rerendered.   So the element that had the non-working command link wasn't in the list.  

 

Since it was in the database, I expected to see a call to the method and the code execute.  However, salesforce says that the view state is the link between the method being called and the java script event.  Since the viewstate was updated when the list was updated, the viewstate copy of the list didn't have that entry and thus the call failed but nothing was in the log.

 

Salesforce said they are considering making a log entry for debugging when this happens and they are also considering listing this scenario under the documentation / best practices.

 

FYI & Thanks

This was selected as the best answer
BDArnzBDArnz

So other than having something show up in the log, what exactly was changed to get the non-functioning link to work?

 

I'm having this issue now after rolling over to SF 13.  I wasn't having it before.  I have non-functioning command links that are only associated with the first item on my list in the pageblock.  Every command link for items after the 1st work just fine.  I can't get the first ones to work.

 

Right now I'm adding an item to the list and then immediately adding a second (and others) that work fine while I 'pretend' the first item isn't on the list.

colemabcolemab

BDArnz,

 

In my case the child pageblock wasn't being re-rendered when the list behind it was updated.  When that list was updated in the view state it no longer contained a reference to that record so the java-script reference in the 'stale' child pageblock became invalid.   The odd thing was that it didn't show up in the apex log at all and that is what got me.   I was new to salesforce at that time and once they explained that visual force pages are built on the Model View Controller (M-V-C) design pattern, it made sense.

 

Sorry but I am not exactly sure how the spring 13 release caused problems for you.   I can say that I have seen many updates break already working code on the salesforce platform due to the fact that not all changes are versioned as some of the documentation leads you to believe.

 

Thanks