• Brooke Baker
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Does anyone know how to get the inputfield for a reference field/lookup working on Salesforce1.

Ive built a custom componet with a recordEditform that is launched from an object action button and shows the lookups correctly. But in Salesforce1 it shows just a input text fields. 

This one took countless hours to isolate and even then I battle to accept the conslusion I have reached.

Scenario:
1. We have a trigger on Opportunity that posts a FeedItem to a specific Chatter group when an Opportunity is Closed Won - a digital reining of the bell. We set the CreatedBy field on the new FeedItem to a specific userid so the post comes from that user.
2. When Opps are updated by normal users this trigger works like a bomb and the Chatter post lets the whole sales team know about the win.  The post is seen to come from the designated user
3. We have a site where customers can place an order online which created a new Opportunity of a specific record type in the controller and then updates that Opportunity to Closed Won.  The traigger is written to ignore these online closed won opportunities and not post to Chatter, but of course the trigger is still called.

The Problem:
The creation of the opportunity through the controller from the site fails itermittently.  The failure is in the trigger and the message is "Field is not writeable: FeedItem.CreatedById".  The line of code in the trigger is not being executed as the opportunity does not meet the criteria and a FeedITem is not created.

The Debug Log:
This doesn't shed any light on the problem as it simple ends at the "insert newOpportunity;" statement and does not show any of the execution in the trigger.  It is as if the code hit a brick wall and just stopped.

The Problem:
After many, many hours of painstaking trial and error, debugging, changing permissions and more we were still gettting this error ittermitently. FInally I spotted a pattern. The times that it worked through the site controller was when there had been an opportunity updated recently by a normal user (< a few minutes before the udpate from the site).  So after a successful update by an nromal user there is a window in whcih updates from the site go through.

The Cause?
Could it be that the trigger is compiled on demand when the internal user updates an opp, is then held in a cache for a while and if the site does an updated while it is cached it works?  After some time has elapsed the compiled trigger it purged and if the site then tries an update it fails due to the running user "Site Guest User" during compilation?

I would love some input on this.  Obviously a solution would be great but I wonder if anyone else has ever had a similar issue?

Regards

Derek