• sfdc_1
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 5
    Replies
I have two permission set (API Name: RDM014 and RDM015) which need to declare inside custom metadata.

1)Can I defined directly this permission set inside record of custom metadata which have fields name BU logic as below: 
BU Logic Fields:RecordType.DeveloperName,Obr_Has_Onboarding__c,RDM014,RDM015(Go through attached image of custom metadata)


2)Now this permission set declared over custom metadata, I need to call this inside apex class have method 'evaluateFields' using else if condition in below logic.

Please help me out how to call this permission set of custom metadata inside below apex method using else if

List<String> buLogicFields=String.isBlank(businessUnitDataList[0].BU_Logic_Fields__c) ? new List<String>() :  businessUnitDataList[0].BU_Logic_Fields__c.split(',');
   
   private String evaluateFields(List<String> buLogicFields, sObject sObj){
        String recordValueString='';
        for(String objFld:buLogicFields){
            String fieldVal='';
            if(objFld.contains('RecordType.')){
                fieldVal=getRecordTypeName(objFld,(Id)sObj.get('RecordTypeId'));
            }else{
                fieldVal=String.valueOf(sObj.get(objFld));
            }
            recordValueString+=(recordValueString=='')?fieldVal:(','+fieldVal);
        }
        return recordValueString;
    }
    
    private String getRecordTypeName(String fieldName, Id recordTypeId){
        list<RecordType> rt = [SELECT Id,Name, DeveloperName FROM RecordType WHERE SobjectType= :objectName and id =:recordTypeId];
        if((fieldName=='RecordType.DeveloperName')&&(rt.size() == 1)){
            return rt[0].DeveloperName;
        }else if((fieldName=='RecordType.Name')&&(rt.size() == 1)){
            return rt[0].Name;
        }
        return null;
    }custom data
  • November 15, 2022
  • Like
  • 0
Hi Can anyone help me out to cover the code coverage of below email serivce class. I am getting 60% coverage with my code. please help me out since i am very new to test class.
class:
global class UpdateCustomerEmail implements Messaging.InboundEmailHandler  {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
                                                           Messaging.InboundEnvelope envelope ) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
//String subToCompare = 'Customer creation in  SAP : 001C1000002LOrzIFG';    
String subToCompare = email.subject;                                   
String accid1=subToCompare.substringAfterLast(':');
String   accid= accid1.trim();                                                          
system.debug('1st'+accid);
system.debug('2st'+subToCompare);
if(email.subject.equalsIgnoreCase(subToCompare))
 {

String getLabelName = Label.Status;
List<Account> aa=new list<account>(); 
account a= [SELECT Id, Name,Status__c,Customer_Code__c FROM Account WHERE Id =:accid];
system.debug(accid);
a.Customer_Code__c='990';
a.Status__c='Customer created in SAP';
aa.add(a);
update aa;       
} return result;  
 }
}

My test class:
@isTest
private class  testCreateContactFrmEmail {
    static testMethod void validatedata()
    {
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
        email.subject = 'Customer creation in SAP :';
        email.plainTextBody = 'FromEmail';
        //env.fromAddress = 'abcd@test.com';
        UpdateCustomerFromEmail upc=new UpdateCustomerFromEmail();
        upc.handleInboundEmail(email, env );
        
Messaging.InboundEmailResult result = upc.handleInboundEmail(email, env);
        System.assertEquals( result.success  ,true);        
    }
    
    @testSetup static void setup() {
        // Create common test accounts
        List<Account> testAccts = new List<Account>();
        
        for(Integer i=0;i<100;i++) {
            testAccts.add(new Account(Name = 'TestAcct'+i,Status__c='Customer created in SAP',Customer_Code__c='990'));
        }
        insert testAccts;
    }
    
    
       static testMethod void validate3(){
        
        list<account> testAccts=new list<account>();
         Account testAcs = [SELECT Id,Status__c,Customer_Code__c FROM Account WHERE Name='TestAcct0' LIMIT 1];
        // Modify first account
        testAcs.Customer_Code__c = '990';
        // This update is local to this test method only.
               testAccts.add(testAcs); 
       Test.startTest();
        update testAccts;
        Test.stopTest();
     
       // System.assertEquals('990',testAcs.Customer_Code__c);

//System.assertEquals('990', '990');
        
    }
}
  • March 13, 2022
  • Like
  • 0
i have one scenario in salesforce please let me know what to do in this case.

i have page(custom object) have lookups to relate to both Account and Opportunity. 
When records created at Opportunity level, page do not rollup to Account 
Need to populate Account lookup with related Account when page records are created on Opportunities 
  • February 11, 2020
  • Like
  • 0
can some one help me to write test class for below code as i am new to salesforce so i don't have much idea related to test class.

public class permissionset {
public void testOCRmethod() {
List < PermissionSetAssignment > permissionSetList = new List < PermissionSetAssignment > ();
Id permissionSetId = [SELECT id FROM permissionSet WHERE Name = 'test1per'].id;
Set < String > profileSet = new Set < String > { 'test1' };
for (User u: [SELECT ID, UserRole.Name, Profile.Name, IsActive FROM User WHERE Profile.Name IN: profileSet AND IsActive = true])

PermissionSetAssignment psa = new PermissionSetAssignment(PermissionSetId = permissionSetId, AssigneeId = u.Id);
permissionSetList.add(psa);
}
upsert permissionSetList;
}
}
permi
  • January 02, 2020
  • Like
  • 0
i want to automate Connected Apps using apex code
following steps:-
Setup->Apps->Connected Apps->Create New
1.Connected App Name
2.Contact Email
3.Check the 'Enable OAuth' option.
4.Callback URL
5.Selected OAuth Scopes->Full Access.
6.Enable OAuth Settings checked and all other checkbox unchecked.
7.Click Save
 
  • December 20, 2019
  • Like
  • 0
i want to automate Named Credential through apex code 
  • December 20, 2019
  • Like
  • 0
i want to assign 100 different profile with same permission set through code in salesforce 
  • December 18, 2019
  • Like
  • 0
how to access object of the fields through code in salesforce without manually giving any permission to the field while creating (give permission to the field of obejct through code like read,write etc)


 
  • December 16, 2019
  • Like
  • 0
using trigger i have to do scenario 1.create a formula filed domain on lead 2. so, if email filed on lead is abc@xyz.com- domain will be xyz. 3 insert a new lead-take the domain and search system with the  same  domain for existing lead.4. if match found take most recent modified lead and take owner from that lead and assign the same owner to new lead .

plzz let meknow using trigger
Hi Can anyone help me out to cover the code coverage of below email serivce class. I am getting 60% coverage with my code. please help me out since i am very new to test class.
class:
global class UpdateCustomerEmail implements Messaging.InboundEmailHandler  {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
                                                           Messaging.InboundEnvelope envelope ) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
//String subToCompare = 'Customer creation in  SAP : 001C1000002LOrzIFG';    
String subToCompare = email.subject;                                   
String accid1=subToCompare.substringAfterLast(':');
String   accid= accid1.trim();                                                          
system.debug('1st'+accid);
system.debug('2st'+subToCompare);
if(email.subject.equalsIgnoreCase(subToCompare))
 {

String getLabelName = Label.Status;
List<Account> aa=new list<account>(); 
account a= [SELECT Id, Name,Status__c,Customer_Code__c FROM Account WHERE Id =:accid];
system.debug(accid);
a.Customer_Code__c='990';
a.Status__c='Customer created in SAP';
aa.add(a);
update aa;       
} return result;  
 }
}

My test class:
@isTest
private class  testCreateContactFrmEmail {
    static testMethod void validatedata()
    {
        Messaging.InboundEmail email = new Messaging.InboundEmail() ;
        Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();
        email.subject = 'Customer creation in SAP :';
        email.plainTextBody = 'FromEmail';
        //env.fromAddress = 'abcd@test.com';
        UpdateCustomerFromEmail upc=new UpdateCustomerFromEmail();
        upc.handleInboundEmail(email, env );
        
Messaging.InboundEmailResult result = upc.handleInboundEmail(email, env);
        System.assertEquals( result.success  ,true);        
    }
    
    @testSetup static void setup() {
        // Create common test accounts
        List<Account> testAccts = new List<Account>();
        
        for(Integer i=0;i<100;i++) {
            testAccts.add(new Account(Name = 'TestAcct'+i,Status__c='Customer created in SAP',Customer_Code__c='990'));
        }
        insert testAccts;
    }
    
    
       static testMethod void validate3(){
        
        list<account> testAccts=new list<account>();
         Account testAcs = [SELECT Id,Status__c,Customer_Code__c FROM Account WHERE Name='TestAcct0' LIMIT 1];
        // Modify first account
        testAcs.Customer_Code__c = '990';
        // This update is local to this test method only.
               testAccts.add(testAcs); 
       Test.startTest();
        update testAccts;
        Test.stopTest();
     
       // System.assertEquals('990',testAcs.Customer_Code__c);

//System.assertEquals('990', '990');
        
    }
}
  • March 13, 2022
  • Like
  • 0
I created a simple LWC to be called from Actions and added to the "Salesforce Mobile and Lightning Experience Actions" section in the page layout.  The "Send Mail LWC" action displayed and worked properly when I logged in from a web browser, but not displaying in the Action list in Salesforce Mobile app.

Did I miss any configuration?

Page Layout Config
Page Layout Configuration

Browser Display
Browser


Mobile
User-added image

LWC Component
dispatchIssue.html

<template> </template>

dispatchIssue.js
import { LightningElement, api } from 'lwc';
export default class DispatchIssue extends LightningElement {
    @api invoke() {
        console.log("Hi, I'm an action.");
    }
}


dispatchIssue.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <masterLabel>Dispatch Issue</masterLabel>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
        <target>lightning__RecordPage</target>        
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
          <actionType>Action</actionType>        
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">
            <supportedFormFactors>
                <supportedFormFactor type="Large" />
                <supportedFormFactor type="Small" />
            </supportedFormFactors>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
i have one scenario in salesforce please let me know what to do in this case.

i have page(custom object) have lookups to relate to both Account and Opportunity. 
When records created at Opportunity level, page do not rollup to Account 
Need to populate Account lookup with related Account when page records are created on Opportunities 
  • February 11, 2020
  • Like
  • 0
i want to assign 100 different profile with same permission set through code in salesforce 
  • December 18, 2019
  • Like
  • 0
Hi Everyone,

My Scenario is create two fields
product category” as the first lookup(Product2) and then the “Product Name/Code” as the second lookup(Product2) into Child Object (Request__c).

Note:  here main problem is reffering same Parent Object(Product2) in Child Object

Here my client expecting first lookup user going to select perticuler Category 

Product Category 
Samsung
IPHONE
SONY

Samsung :(user Clicks First lookup values is Samsung in second lookup need to display some dependeny mentioned below )

Product  Name/code(Lookup)
S-3652
S-2564
S-1234

IPHONE:(user Clicks First lookup values is IPHONE in second lookup need to display some dependeny mentioned below )

Product name/code(Lookup)
I6
I7
I8

Sony:(user Clicks First lookup values is Sony in second lookup need to display some dependeny mentioned below )

Product Name/code(Lookup)
Sony-1234
Sony-5664
Sony-4568

I'm implemented same functionlity using picklist dependency its working fine but my client expecting above scenario. 

Can you please guide me how to achive this scenrion in Salesforce .


PFA

User-added image