• MUSFAR KT 6
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 6
    Replies
public class Promise implements Finalizer, Queueable {


    private Function resolve;

    private Function reject;

    private Promise next;

    private Function last;

    private Function onError;

    private Object result;

    private Object arg;



    public Promise(Function resolve, Function reject) {
        this.resolve = resolve;
        this.reject = reject;
    }

    public void execute(System.QueueableContext ctx) {
        System.attachFinalizer(this);
        result = this.resolve.apply(this.arg);
    }

    public void execute(System.FinalizerContext ctx) {

    }

    public Promise then(Promise promise) {
        if(this.next != null) {
            this.next = next;
        } else {
            this.next.then(promise);
        }
        return this;
    }

    public void setArg(Object arg) {
        this.arg = arg;
    }

    public Promise onCatch(Function onError) {
        this.onError = onError;
        return this;
    }
    
}
public with sharing class CrossObjectWorkflowACtionSelectorImpl extends fflib_SObjectSelector implements CrossObjectWorkflowACtionSelector {
  public List<Schema.SObjectField> getSObjectFieldList() {
    return new List<Schema.SObjectField>{
      x_object_workflow_action__mdt.id,
      x_object_workflow_action__mdt.child_object_name__c,
      x_object_workflow_action__mdt.lookup_field_name__c,
      x_object_workflow_action__mdt.task_key_value__c,
      x_object_workflow_action__mdt.rule_key_value__c,
      x_object_workflow_action__mdt.automation_direction__c,
      x_object_workflow_action__mdt.triggering_status__c,
      x_object_workflow_action__mdt.child_start_status__c,
      x_object_workflow_action__mdt.child_destination_status__c
    };
  }
  public Schema.SObjectType getSObjectType() {
    return x_object_workflow_action__mdt.sObjectType;
  }
  //get relevante crossed object actions by parent object type and triggering status
  public List<x_object_workflow_action__mdt> getParentToChildActions(
    String parentObjectType,
    Set<String> triggeringStatuses
  ) {
    return Database.query(
      newQueryFactory()
        .setEnforceFLS(false)
        .selectFields(getSObjectFieldList())
        .setCondition(
          'parent_object_name__c = :parentObjectType AND automation_direction__c = \'Parent to Children\' AND triggering_status__c IN :triggeringStatuses AND active__c = true'
        )
        .toSOQL()
    );
  }
}
public with sharing class InvocableSelectionUpdateWorkAround {

    public InvocableSelectionUpdateWorkAround() {

    }

    /**
     * For a given SObject, for each selection field replace it as the String version of itself.
     * @param cleanse - The Sobject to cleanse
     */
    public void performWorkAround(SObject cleanse) {
        DescribeSObjectResult describe = Utils.getSObjectTypeDescribe(cleanse.getSObjectType());
        Map<String,Schema.SObjectField> fieldMap = describe.fields.getMap();

        for(String fieldName : cleanse.getPopulatedFieldsAsMap().keySet()) {
            if(fieldMap.get(fieldName).getDescribe().getType() == Schema.DisplayType.PICKLIST) {
                cleanse.put(fieldName, String.valueOf(cleanse.get(fieldName)));
            }
        }
    }
}
public with sharing class fflib_QualifiedMethodAndArgValues
{
    private final fflib_QualifiedMethod qm;
    private final fflib_MethodArgValues args;
    private final Object mockInstance;

    public fflib_QualifiedMethodAndArgValues(fflib_QualifiedMethod qm, fflib_MethodArgValues args, Object mockInstance)
    {
        this.qm = qm;
        this.args = args;
        this.mockInstance = mockInstance;
    }

    public fflib_QualifiedMethod getQualifiedMethod()
    {
        return qm;
    }

    public fflib_MethodArgValues getMethodArgValues()
    {
        return args;
    }

    public Object getMockInstance()
    {
        return mockInstance;
    }

    public override String toString()
    {
        return qm + ' with args: [' + String.join(args.argValues, '],[') + ']';
    }
}
global with sharing class InvocableCrossObjectActions {
  
  @InvocableMethod
  global static void processCrossObjectActions(List<SObject> items) {
    CrossObjectActionService service = (CrossObjectActionService)PlatformExtensionsApplication.service.newInstance(CrossObjectActionService.class);
    service.processCrossObjectActions(new CrossObjectActionContext(items));
  }
}
how to use fieldset in lightning component for creation of  form edit and view in the account object
public class UpdateOTP{
    public static void saveData(String email) {
        List<Account> accsToUpdate = new List<Account>();
       for ( Account a : [SELECT Id,OTP__c,Email__c  from Account WHERE Email__c =:email]) {
            if(a.OTP__c == null) {             
                Integer len = 5;
                Blob blobKey = crypto.generateAesKey(128);
                String key = EncodingUtil.convertToHex(blobKey);
                String pwd = key.substring(0,len);
                System.debug('OTP**** '+pwd); 
                     a.OTP__c = pwd;               
                    }
           
             accsToUpdate.add(a);
            update accsToUpdate;
                  
        }
       
    }
    }
trigger Update_city_Acc on Account (after update) {
    set<id> ids=new set<id>();
    for(account a :trigger.new){
        
        if(a.city__c!=trigger.oldmap.get(a.id).city__c){
            ids.add(a.id);
            
        }
    }
List<opportunity>opp=[select id,City__c,Accountid from opportunity where accountid IN:ids];
    for(opportunity op:opp){
        op.City__c=trigger.newmap.get(op.accountid).city__c;
    }
    
}

unit test time its not working.
trigger Prefix_Dr on Lead (before insert,before update) {
    for(lead L:trigger.new){
       L.FirstName='Dr.'+L.FirstName;
        }
}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@istest
public class Prefix_Dr_test {
    testmethod static void test(){
        Lead L=New Lead();
        L.FirstName='Dr.Midul';
        L.LastName='ahmed';
        L.Company='sfdc';
        L.Status='Working-contacted'; 
        insert L;
        
        Lead Le=[select Id,firstname,lastname from lead where company='sfdc'];
       System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.');
           
    }


here test class is showing error
public with sharing class InvocableSelectionUpdateWorkAround {

    public InvocableSelectionUpdateWorkAround() {

    }

    /**
     * For a given SObject, for each selection field replace it as the String version of itself.
     * @param cleanse - The Sobject to cleanse
     */
    public void performWorkAround(SObject cleanse) {
        DescribeSObjectResult describe = Utils.getSObjectTypeDescribe(cleanse.getSObjectType());
        Map<String,Schema.SObjectField> fieldMap = describe.fields.getMap();

        for(String fieldName : cleanse.getPopulatedFieldsAsMap().keySet()) {
            if(fieldMap.get(fieldName).getDescribe().getType() == Schema.DisplayType.PICKLIST) {
                cleanse.put(fieldName, String.valueOf(cleanse.get(fieldName)));
            }
        }
    }
}
public with sharing class fflib_QualifiedMethodAndArgValues
{
    private final fflib_QualifiedMethod qm;
    private final fflib_MethodArgValues args;
    private final Object mockInstance;

    public fflib_QualifiedMethodAndArgValues(fflib_QualifiedMethod qm, fflib_MethodArgValues args, Object mockInstance)
    {
        this.qm = qm;
        this.args = args;
        this.mockInstance = mockInstance;
    }

    public fflib_QualifiedMethod getQualifiedMethod()
    {
        return qm;
    }

    public fflib_MethodArgValues getMethodArgValues()
    {
        return args;
    }

    public Object getMockInstance()
    {
        return mockInstance;
    }

    public override String toString()
    {
        return qm + ' with args: [' + String.join(args.argValues, '],[') + ']';
    }
}
how to use fieldset in lightning component for creation of  form edit and view in the account object
trigger Prefix_Dr on Lead (before insert,before update) {
    for(lead L:trigger.new){
       L.FirstName='Dr.'+L.FirstName;
        }
}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@istest
public class Prefix_Dr_test {
    testmethod static void test(){
        Lead L=New Lead();
        L.FirstName='Dr.Midul';
        L.LastName='ahmed';
        L.Company='sfdc';
        L.Status='Working-contacted'; 
        insert L;
        
        Lead Le=[select Id,firstname,lastname from lead where company='sfdc'];
       System.assertEquals(Le.FirstName.ContainsIgnoreCase('Dr.'),'Dr.');
           
    }


here test class is showing error
​I keep getting

Challenge Not yet complete... here's what's wrong: 
The 'Top Laptop Industry' lens was not found. Please follow the requirements and ensure everything is setup correctly


I have named the Lens as step 2 - Enter D01 - Laptops Salespeople - Wall of Fame as the title AND/OR result set Top Laptop Industry

Neither seem to work. I have refresed the screen, even cleared cookies and rebooted the computer. 

Hi everyone,

 

I just started using couple months ago and now have just started exploring triggers.

I am looking to create new lead records after case has been closed if it fulfills certain criterias.

Hope someone could help me out here; details are as below.

 

To create new Lead record when from Case object:-

 

Status=Closed

and

Receive_survey_form_future_promotions__c=True

and

(E_mail_c or SuppliedEmail)!=null

 

The Lead record field name mapping for insertion are as follows:-

From Case object ==> To Lead object

Name_c or SuppliedName ==> LastName

E_mail_c or SuppliedEmail ==> Email

Contact_Number__c ==> MobilePhone

 

Lead status will always be New.

Lastly, the lead will only be created if a search based on the email from (E_mail_c or SuppliedEmail) isn't existant in any Lead records.

 

Hope to hear from someone and thanks in advance.

 

P.S. Just wondering, can an email message be triggered to a particular default email if the Lead record isn't created due to its existance in Lead already?

 

Regards,

Ravin

  • February 21, 2012
  • Like
  • 0