• Lexi Kans
  • NEWBIE
  • -1 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    Replies
We are receiving spam email through email-to-case. What is the best way to auto discard these cases and how do you do it in Salesforce? 
Hi there, I am trying to write a code which would help me to grant read accesses to the fields on Permission sets. Please help me with this code below. It does not show any error but also it is not working.
Any advice, help will be highly appreciated.
public class GrantFieldAccess {

    public void grantFieldReadAccess() {
        List<String> fieldAPINames = new List<String>{
            'CustomeField1',
            'CustomeField2'
        };

        List<PermissionSet> permissionSets = [SELECT Id FROM PermissionSet WHERE Name IN ('PermissionSet1', 'PermissionSet2', 'PermissionSet3' )];

        List<FieldPermissions> fieldPermissionsList = new List<FieldPermissions>();

        for (PermissionSet ps : permissionSets) {
            for (String fieldAPIName : fieldAPINames) {
                FieldPermissions fieldPerm = new FieldPermissions(
                    SobjectType = 'Account',
                    Field = fieldAPIName,
                    ParentId = ps.Id,
                    PermissionsRead = true
                );
                fieldPermissionsList.add(fieldPerm);
            }
        }

        try {
            upsert fieldPermissionsList;
            System.debug('Field access granted successfully.');
        } catch (Exception ex) {
            System.debug('An error occurred: ' + ex.getMessage());
        }
    }
}

 
Hi, can anyone help me combine these two formulas on a date field please?

IF the Portfolio is Interfaces and the Status is Agreed and the EA Action is one of 3, then the date should be Expected Submission Date -28, +14 or +42.
PLUS
IF the Portfolio is Interfaces and the Status is Invited and the EA Action is First Invitation Chaser, then the date should be Invite email sent + 28 days

I have them both working on separate fields, but can't get them into one formula.

Formula 1:

IF( AND( Journal_for_Article_use__r.Portfolio__c = "Interfaces",
ISPICKVAL( Status__c , "AGR - Agreed to submit")
),
CASE( TEXT( EA_Action__c ),
"Submission Reminder", (Expected_Submission_Date__c - 28),
"First Submission Chaser", (Expected_Submission_Date__c + 14),
"Second Submission Chaser", (Expected_Submission_Date__c + 42),
Null
),
Null
)

Formula 2:

IF( AND(
Journal_for_Article_use__r.Portfolio__c = "Interfaces",
ISPICKVAL( Status__c , "INV - Invited")
),
CASE( TEXT( EA_Action__c ),
"First Invitation Chaser", (Invite_email_sent__c +28),
Null),
Null)
Apoligies I'm still rather new and learning. My problem is I have a list of parent account with the field Funded_Deals__c and I need to find all child accounts related to their respective parent accounts, then do the sum of that field for all child accounts related to the parent account and update the parent account with that sum. I feel like the way to do this would be to have 2 lists one for parent and one for child accounts and then map the data but I need a little help figuring out exactly how to do it. 
We have an object that got created through to the application package and we are discontinuing that product and need to copy the object, data and the files from that object to a new one. Please guide us how to do that

Hello everyone, 

I am a fresh new developer and recently I wrote my first method in a class of an existing project. I need to write also a unit test for this class but I am getting an error and since I just recently started writind code in general I am struggling to deal with the issue. Any help would be much appreciated. 

Below is my method: 

// update the accounts of Type 'Other'PEM with the PEM of their related 'Constituent' Account
    public static void updateRelatedAccountPEM(Set<String> setAccountId) {
    // query all relevant relationships, where the related person is account type 'Other' and person is 'Constituent'
         Map<Id,Account> accountMap = new Map<Id,Account>();
            for (Relationship__c relationship : [
                SELECT Id, Person__c, Related_Person__c, Person__r.OwnerId, Related_Person__r.OwnerId
                FROM Relationship__c
                WHERE Person__r.RecordType.DeveloperName = :Utils_Constants.ACCOUNT_CONSTITUENT_RT
                AND Related_Person__r.RecordType.DeveloperName = :Utils_Constants.ACCOUNT_OTHER_RT
                AND (Person__c IN :setAccountId
                OR Related_Person__c IN :setAccountId)
            ]) {
                if(relationship.Person__r.OwnerId != relationship.Related_Person__r.OwnerId) {
                   accountMap.put(
                    relationship.Related_Person__c,
                    new Account(Id = relationship.Related_Person__c, OwnerId = relationship.Person__r.OwnerID)
                    );
                }
            }
            if (!accountMap.isEmpty()) {
                Database.SaveResult[] result = Database.update(accountMap.values(), false);
                Utils_Methods.writeErrorLog(
                    accountMap.values(),
                    result,
                    'AccountService.updateRelatedAccountPEM'
                );
            }
     }

For Data Creation I use the following method: 

global static final TestDataFactory.Template PERSONAL_RELATIONSHIP = new TestDataFactory.Template(
        Relationship__c.SObjectType,
        new Map<SObjectField, Object>{
            Relationship__c.Name => 'testRelationship {!index}',
            Relationship__c.Person__c => AccountTestDataTemplates.CONSTITUENT,
            Relationship__c.Related_Person__c => AccountTestDataTemplates.OTHER,
            Relationship__c.RecordTypeId => Utils_Constants.RELATIONSHIP_PERSONAL_RT
        }
    );

My Unit Test is:

@IsTest
public class updatePEMTest {
    @IsTest
    public static void testUpdateRelatedAccountPEM() {
        // Create test data using TestDataFactory
        TestDataFactory factory = new TestDataFactory();
        List<Relationship__c> relationships = (List<Relationship__c>)factory.create(AccountTestDataTemplates.PERSONAL_RELATIONSHIP);
        
               
        // Call the method being tested
        Set<String> setAccountId = new Set<String>();
        for (Relationship__c relationship : relationships) {
            setAccountId.add(relationship.Person__c);
            setAccountId.add(relationship.Related_Person__c);
        }
        
        Test.startTest();
        AccountService.updateRelatedAccountPEM(setAccountId);
        Test.stopTest();
        
        // Verify the results
        Map<Id, Account> updatedAccounts = new Map<Id, Account>([SELECT Id, OwnerId FROM Account WHERE Id IN :setAccountId]);
        for (Relationship__c relationship : relationships) {
            Account relatedAccount = updatedAccounts.get(relationship.Related_Person__c);
            System.assertEquals(relationship.Person__r.OwnerId, relationship.Related_Person__r.OwnerId);
        }
    }
}


The error I receive on the Unit Test is: 

Incompatible types since an instance of SObject is never an instance of List<Relationship__c>

Any feedback/help would be much appreciated! 

I have a custom label which has a url, there is a utility item, when i click on the utility, it should get redirected to the link in custom label. can I do this directly , or should i write lightning component for this. 
Please help
I have an org with Enhanced Recurring Donations enabled. I have historic data that I would like to enter but cannot figure out how. When I try to make a Recurring Donation, I cannot figure out how to get the historic opportunities in there, even when I set the Effective Date and Date Established are in the past.

Any help would be much appreciated!
Hello All. Once a custom object has already been created. How do you Launch New Custom tab Wizard ?
I do not see Object Creation Options.

Thank you in advance foryour answers