• so_mayank
  • 30 Points
  • Member since 2016

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 13

How to create trigger files dynamically for custom objects via apex?

Thanks, Shweta
As the standard approach(mentioned below) is not applicable for Custom Object.
<apex:outputLink value="{!URLFOR($Action.Account.ChangeOwner,account.id)}">Change Owner</apex:outputLink>

I have a visualforce page implementing a change owner link for a custom object similar to below.
<apex:outputLink value="{!$CurrentPage.parameters.id}/a?retURL=%2F{!$CurrentPage.parameters.id}"> [Change] </apex:outputLink>

First Approach works in Salesforce classic but breaks in lighting saying 'The page is not available in lightning'.

Is there a way to make the change owner link work in lightning?

How to create trigger files dynamically for custom objects via apex?

Thanks, Shweta
Is there any possiblity of implementing a Wiki solution to be embedded in one of the objects. If yes, how?

when we trying to open the opportunity we are getting below error . can you please suggest here 
Too many SOQL queries: 101 
An unexpected error has occurred. Your development organization has been notified.

  • November 29, 2018
  • Like
  • 0
Hi All,
I need help in writing test class for trigger. I have written but its giving only 65%. Please help me.
trigger test1 on obj1__c (after insert, after update)
if(trigger.isAfter&& (trigger.isinsert || trigger.isUpdate))
public class test3
    public static void method1(List<Obj1__c> o1)
        map<string, obj1__c> ObjMap = new map<string, obj1__c>();
    for(obj1__c obj: o1)
        if (obj.Shared_Field__c != Null)
            ObjMap.put(obj.Shared_Field__c, obj);
    List<obj2__c> obj2l = [SELECT Id, Shared_Field__c, F1__c,f2__c 
                        FROM obj2__c WHERE Shared_Field__c IN :ObjMap.KeySet()];
    List<obj2__c> obj2list = new List<obj2__c>();
    for(obj2__c c: obj2l)
        obj1__c obj = ObjMap.get(c.Shared_Field__c);
        c.f1__c = obj.f1__c;
        c.f2__c = obj.f2__c;
    if(obj2list.size() > 0)
        update obj2list;

Thanks in Advance

* Controller class for C_Header component
public without sharing class C_HeaderCntl {
    public static String getContactTypeDetail(){
        return C_Utilities.getContactTypeDetail();
  • November 29, 2018
  • Like
  • 0

I need to create a batch class that will schedule to run every Friday that will automatically approve Items that are pending from Rep's Approval so that it will proceed to the next level of approver which is their managers, my code is not working here is my code: 

global class PTMS_autoApproveRepBatchable implements Database.batchable<sObject>, Database.Stateful {

    global Iterable<sObject> start(Database.BatchableContext info) {
        return Database.getQueryLocator(
            [Select Id, Auto_Approval__c FROM Professional_Target_List_Line_Item_esi__c WHERE Rep_Approval__c = True AND Proposed_Rep_Approval_Status__c = 'Pending' AND Id = 'a203F000000H0noQAC']);

    global void execute(Database.BatchableContext info, List<Professional_Target_List_Line_Item_esi__c> pendPTLI){
        system.debug('Ming'+ pendPTLI.size());
        Set<Id> pendingRepPTLIset = new Set<Id>();
        List<Professional_Target_List_Line_Item_esi__c> ptliToUpdate = new List<Professional_Target_List_Line_Item_esi__c>();
        for(Professional_Target_List_Line_Item_esi__c pendingRepPTLI : pendPTLI){
                pendingRepPTLI.Auto_Approval__c = True;
                system.debug('Ming2'+ pendingRepPTLIset);
                try {
                    update ptliToUpdate;
                catch(DmlException e){
                    System.debug('exception caught :' + e.getMessage());    
                Approval.ProcessWorkitemRequest[] prWkItems = New Approval.ProcessWorkItemRequest[]{};
                ProcessInstance[] pi = [Select ID, Status, TargetObject.Name,
                (SELECT Id, ActorId, ProcessInstanceId FROM Workitems),
                (SELECT Id, StepStatus, Comments FROM Steps) From ProcessInstance
                Where TargetObjectID IN :pendingRepPTLIset AND Status = 'Pending'];
                for(ProcessInstance instance : pi){
                    for(ProcessInstanceWorkItem workItem : instance.WorkItems){
                        Approval.ProcessWorkitemRequest prWkItem = new Approval.ProcessWorkitemRequest();
    global void finish(Database.BatchableContext info){   
I am updating a custom task (Milestone Tasks) status to completed. It is throwing an exception:

Review the following errors
CCMI.TaskConfiguration: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Z46000003E4s2EAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CCMI.TaskConfiguration: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0Z46000003E95ZEAS; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a0Z46000003E95Z) is currently in trigger CCMI.TaskConfiguration, therefore it cannot recursively update itself: [] (CCMI): [] (CCMI)

When I try to pull up the code I started with TaskConfiguration but it shows (hidden) in the dev console. Any help you can provide in trouble shooting this would be appreciated. 
I am currently working through the "Getting Started with APEX Unit", and the tutorial mentions an "Apex Class Library" where the descriptions of the Salesforce: 
"The EmailManager class has a public method (sendMail()) that sends email and uses built-in Messaging methods of the Apex class library. Also, this class has a private helper method (inspectResults()), which can’t be called externally because it is private but is used only within the class. This helper method inspects the results of the email send call and is called by sendMail()."

I'm wondering where you can find a description of some of these and other methods. i.e. SendMail(), InspectResults(), etc. Any help would be great. 
Hello Guys

I have been struggling to find a way on how I can call an external web service via apex  which uses OAUTH via REST services. Basically I am trying to access an API on https://api.envisionme.co.za/v1/docs#oauth. Now they use OAUTH to grant access to make calls such as retrieving jobs, candidates etc. They have set up an app on their side with a client_id and a client_secret. Now based on their doc Im suppose to follow a process: make a login call, get a token etc...

I have absolutely no idea how to do this...how do I set up an apex class that will
  1. Login and get the token
  2. Enable me to make those Http POST, GET etc methods
Because ultimately I wanna have a trigger that will call on it to retrieve the data from that external web service.

I do know a bit of apex but I am a rookie when it comes to integration stuff. Please help if you can.

Facebook is seeking a Senior Application Developer to join the Salesforce Developer team and participate in the development, integration and maintenance of Force.com applications.  Facebook has a very creative, fast-paced, innovative culture, and we like to have fun developing cool stuff!  


Send your resume or contact me at: 

Shawn Cook



Facebook is currently building large scalable architecture and using Salesforce as our primary productivity platform.  The Salesforce Developer team works with the most state of the art technology.  At Facebook, we are passionate about the emerging Salesforce technology and offer first-hand access to the latest features and development tools!


This is a full-time permanent position based in our main office in Palo Alto.  Facebook offers full relocation assistance for this role and many other perks.


  • Technical design, configuration, development and testing of Force.com custom applications, interfaces and reports
  • Model, analyze and develop or extend persistent database structures which are non-intrusive to the base application code and which effectively and efficiently implement business requirements
  • Integrate Force.com applications to other Facebook external or internal Business Applications and tools
  • Develop UI and ACL tailored to Facebook employees and suppliers
  • Apply sound release management and configuration management principles to ensure the stability of production environments