• anka lex
  • NEWBIE
  • 4 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
I need an Apex Trigger that will update and move a lead from our Content Syndication queue to the reassignment queue when a lead reaches >80%.  I cannot use a workflow, because that will only kick off on creation or edit, and the lead scoring tabulates by Einstein every hour.  Unless I do a mass update to edit/save and kick off the workflow, Salesforce help has said that an Apex Trigger is the only solution.

I have this code, but I get an error on line 5:  Error: Compile Error: Missing '<EOF>' at 'for' at line 5 column 5

trigger LeadRoutingTrigger on Lead (before update) {
    Group ReassignmentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Reassignment Queue' LIMIT 1];
    Group ContentQueue = [select Id from Group where Type = 'Queue' AND NAME = 'Content Syndication and Events Queue' LIMIT 1];
}
    for(Lead currentLead : Trigger.new) {
        if(currentLead.OwnerId == ContentQueue.Id 
           && currentLead.Lead_Insights_Value__c    > 80) {
               currentLead.OwnerId = ReassignmentQueue.Id;
           }
    }
}

Does anyone have a suggestion?  

Thanks
When I try to compile it get the following error:

Account.Name, ERROR at Row:7: Column:13 Didn't understand relationship 'Account' in field patch. If you are attempting to use a custom relationship .... // // please reference your WSDL or the describe call ..

This refers to the following line ....

               List<User> lstUser = [SELECT 
            Id, 
            ContactId,
            Email,
            Username,
            AccountId, 
            Account.Name, 
            Profile.Name,
            FROM User 
            WHERE Id = :UserInfo.getUserId()];

Using Workbench I can simply use the query and it returns results. I also check field level security on the name field in the account but all profiles have access.Class btw this line is in is still in API v35 .. but I don't think that is causing the issue.
Hello,

We need to automatically Share a Parent record when a Child record is shared to a User through Manual Sharing Button.Can anyone please let me know,How to implment this solution.

Thanks
If you look at the general approach to write a batch, it asks to implement the Batchable interface. The sample code is like this -
global class Accountupdate implements Database.Batchable<sObject> 
{ 
:
:
Here, one thing is absurd - what is the use of datatype sObject in the interface name? Can we write an interface like this?
Also, Salesforce doc says you need to implement start method -
global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
But in an interface how can you define a method with 2 return types? Again, when you actually implement this, you are implementing with just any one of these return types - Database.QueryLocator or Iterable<sObject>. How does this work?

In a nutshell, how has salesforce written the Batchable interface?
 
I'm constantly unable to complete tests because of this error in our sandboxes. If I keep running them over and over they usually complete normally eventually, but it can waste a half hour of my time to get them to complete so I have an accurate test coverage percentage on the class in question.

This has been a problem for over a year, but has been getting worse in the last few months.