• Felix Quinones
  • NEWBIE
  • 65 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 8
    Replies

Hello Everyone,
I'm creating a two flows to pass information from the Stripe Salesforce Connector to the contact and the opportunity object, respectively. The contact object is providing the following error. can someone help me to troubleshoot? 


Error element Create_a_Contact (FlowRecordCreate).
This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: npsp.TDTM_Contact: execution of BeforeInsert caused by: System.NoDataFoundException: Encryption Key Unavailable: The encryption key number 1 used to encrypt this data was deleted. Contact your administrator to get access to the data. (System Code). You can look up ExceptionCode values in the SOAP API Developer Guide.

Flow Details
Flow API Name: Create_a_Contact_from_Customer_Person_in_STRIPE
Type: Autolaunched Flow
Version: 4
Status: Active
Org: Xiente (00D7g000000H78j)

Flow Interview Details
Interview Label: Create a Contact from Customer in STRIPE 10/2/2023, 2:42 AM
Interview GUID: 9724061435764f6df7ec666bd2618aef0e524a-5e36
Current User: Felix Quinones (0054x0000019wxh)
Start time: 10/2/2023, 2:42 AM
Duration: 0 seconds

How the Interview Started
This path runs asynchronously after the original transaction for the triggering record is successfully committed.
Felix Quinones (0054x0000019wxh) started the flow interview.
API Version for Running the Flow: 58
Some of this flow's variables were set when the interview started.
$Record = stripeGC__Stripe_Event__c (a1V7g000001oAHzEAM)

STRIPEGC__V01_CASTCUSTOMER (APEX): Create Contact Object
Inputs:
requestBody = {!$Record.stripeGC__Request_Body__c} ({"type":"customer.created","request":{"idempotency_key":"b753c2f3-ed87-4812-92db-0278c4e4e7dd","id":"req_qfYBsmlz3AxsmW"},"pending_webhooks":1,"livemode":false,"data":{"object":{"test_clock":null,"tax_exempt":"none","shipping":{"phone":"","name":"Benito Santos","address":{"state":"PA","postal_code":"19123","line2":"","line1":"171 Diamante Calle","country":"US","city":"Philadelphia"}},"preferred_locales":[],"phone":null,"next_invoice_sequence":1,"name":"Benito Santos","metadata":{},"livemode":false,"invoice_settings":{"rendering_options":null,"footer":null,"default_payment_method":null,"custom_fields":null},"invoice_prefix":"FE186119","email":"bsantos@example.com","discount":null,"description":"THis is an example","delinquent":false,"default_source":null,"currency":null,"created":1696226131,"balance":0,"address":{"state":"PA","postal_code":"19123","line2":"","line1":"171 Diamante Calle","country":"US","city":"Philadelphia"},"object":"customer","id":"cus_Ok9PtATlWmgW9j"}},"created":1696226131,"api_version":"2022-11-15","object":"event","id":"evt_1Nwf6OL3g4suNTxU9Xkp4IVV"})
Outputs:
metadata (Metadata : (Error rendering: stripeGC.Metadata))
subscriptions (null)
livemode (false)
sources (null)
testClock (null)
description (THis is an example)
discount (null)
taxIds (null)
balance (0)
shipping (Shipping : (Error rendering: stripeGC.Shipping))
invoicePrefix (FE186119)
delinquent (false)
cashBalance (null)
r_object (customer)
id (cus_Ok9PtATlWmgW9j)
r_currency (null)
email (bsantos@example.com)
nextInvoiceSequence (1)
invoiceCreditBalance (null)
address (Address : (Error rendering: stripeGC.Address))
taxExempt (none)
created (1,696,226,131)
tax (null)
preferredLocales ([])
phone (null)
invoiceSettings (InvoiceSettingCustomerSetting : (Error rendering: stripeGC.InvoiceSettingCustomerSetting))
name (Benito Santos)
defaultSource (null)

CREATE RECORDS: Create a Contact
Create one Contact record where:
Email = {!Create_Contact_Object.email} (bsantos@example.com)
FirstName = {!FirstName} (Benito)
HomePhone = {!Create_Contact_Object.phone} (null)
LastName = {!LastName} (Santos)
MailingCity = {!Create_Contact_Object.address.city} (Philadelphia)
MailingCountry = {!Create_Contact_Object.address.country} (US)
MailingPostalCode = {!Create_Contact_Object.address.postalCode} (19123)
MailingState = {!Create_Contact_Object.address.state} (PA)
MailingStreet = {!Create_Contact_Object.address.line1} (171 Diamante Calle)
MobilePhone = {!Create_Contact_Object.phone} (null)
RecordTypeId = 0124x000000uBaaAAE
npe01__PreferredPhone__c = Mobile
npe01__Preferred_Email__c = Personal
Result
Failed to create record.

Error Occurred: This error occurred when the flow tried to create records: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: npsp.TDTM_Contact: execution of BeforeInsert caused by: System.NoDataFoundException: Encryption Key Unavailable: The encryption key number 1 used to encrypt this data was deleted. Contact your administrator to get access to the data. (System Code). You can look up ExceptionCode values in the SOAP API Developer Guide.


Salesforce Error ID: 2072553734-436631 (-653010637)

Hello All, 

I'm trying to send a calendar invite to specific departments any time a new Deliverable record is created. To do that, I established several Apex Classes (below). After many changes, it continue giving me a Code Coverage Failure. Here, I have remove the client id, client secret key, tenant ID, and emails. 

Error: Your code coverage is 71%. You need at least 75% coverage to complete this deployment.

Questions: 

  1. How can I improve the different Apex Classes to increase coverage failure?
  2. What can I do different to received the same result? 
  3. Any free app or low cost that could do this? 

OutlookCalendarInvite

public class OutlookCalendarInvite {
    public static void sendCalendarInvite(List<npsp__Grant_Deadline__c> deadlines) {
        // Query related Opportunities
        Set<Id> oppIds = new Set<Id>();
        for (npsp__Grant_Deadline__c deadline : deadlines) {
            oppIds.add(deadline.npsp__Opportunity__c);
        }
        Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>([
            SELECT Id, Name
            FROM Opportunity
            WHERE Id IN :oppIds
        ]);

        List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();

		for (npsp__Grant_Deadline__c deadline : deadlines) {
            String emailAddress = getEmailByDepartment(deadline.Department__c);
            if (emailAddress == null) {
                System.debug('Email address is null for department: ' + deadline.Department__c);
                continue;
            }

            // Generate the ICS file for the deadline
            NPS_MeetingInviteGenerator icsGenerator = new NPS_MeetingInviteGenerator();
            List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();

			DateTime dueDate = deadline.npsp__Grant_Deadline_Due_Date__c;
			String bodyContent = 'Hello ' + deadline.Department__c + ' Team,\n\n' +
                     'Please find attached the calendar invite for grant opportunity ' + deadline.npsp__Opportunity__c + ' with the following deadline: ' + dueDate + '\n\n' +
                     'Deliverable Type: ' + deadline.npsp__Type__c + '\n\n' +
                     'Deliverable Sub-Type: ' + deadline.SubType__c + '\n\n' +
                     'Requirements: ' + deadline.npsp__Grant_Deliverable_Requirements__c + '\n\n' +
                     'Note: This is an automated message from Salesforce.';

            icsGenerator.meetingSubject = 'Invite - ' + deadline.Name;
            icsGenerator.meetingBody = bodyContent;
            icsGenerator.startDate = dueDate.format('dd/MM/yyyy hh:mm:ss a');
            icsGenerator.endDate = dueDate.addHours(1).format('dd/MM/yyyy hh:mm:ss a');
            icsGenerator.fromAddress = 'salesforce@nscaphila.org';
            icsGenerator.displayName = 'NSCA Salesforce Team';
            icsGenerator.attachmentName = 'MeetingInvite.ics';
            icsGenerator.toAddressList = new List<String> {emailAddress};

            Messaging.EmailFileAttachment meetingInviteIcs = icsGenerator.generateMeetingInvite();       
            fileAttachments.add(meetingInviteIcs);

            // Send the email with the ICS attachment
            NPS_EmailUtility emailUtils = new NPS_EmailUtility();
            emailUtils.toAddressList = new String[] {emailAddress};
            emailUtils.subject = 'Calendar Invite: ' + deadline.Name;

            OrgWideEmailAddress[] orgWideEmailAddr = [select Id from OrgWideEmailAddress];
            if (!orgWideEmailAddr.isEmpty()) {
                emailUtils.orgWideEmailAddrId = orgWideEmailAddr[0].Id;
            }

            emailUtils.body = bodyContent;
            emailUtils.emailAttachmentList = fileAttachments;

            if (!Test.isRunningTest()) {
                emailUtils.sendEmail();
            }
        }
    }

    private static String getEmailByDepartment(String department) {
        if (department == 'Finance') {
            return 'finance@emailexample.org';
        } else if (department == 'Economic Mobility') {
            return 'programs@emailexample.org';
        } else if (department == 'Human Resources') {
            return 'hr@emailexample.org';
        } else if (department == 'Executive Team') {
            return 'executive@emailexample.org';
        } else if (department == 'Property Management') {
            return 'facilities@emailexample.org';
        } else if (department == 'Resource Development') {
            return 'resources@emailexample.org';
        } else {
            return null;
        }
    }
}


OutlookCalendarInviteTest
 

@isTest
private class OutlookCalendarInviteTest {

    @isTest
    static void testSendCalendarInvite() {
        // Create test Opportunity
        Opportunity testOpportunity = new Opportunity(
            Name = 'Test Opportunity',
            CloseDate = Date.today(),
            StageName = 'Prospecting'
        );
        insert testOpportunity;

        // Create test data
        List<npsp__Grant_Deadline__c> testDeadlines = new List<npsp__Grant_Deadline__c>();
        for (Integer i = 0; i < 6; i++) {
            npsp__Grant_Deadline__c deadline = new npsp__Grant_Deadline__c();
            deadline.Name = 'Test Deadline ' + i;
            deadline.npsp__Grant_Deadline_Due_Date__c = Date.today().addDays(i);
            deadline.Department__c = getDepartmentByIndex(i);
            deadline.npsp__Opportunity__c = testOpportunity.Id;
            testDeadlines.add(deadline);
        }

        // Insert test data
        insert testDeadlines;

        // Get the list of deadline IDs
        List<Id> deadlineIds = new List<Id>();
        for (npsp__Grant_Deadline__c deadline : testDeadlines) {
            deadlineIds.add(deadline.Id);
        }

        // Call sendOutlookCalendarInvite method
        Test.startTest();
        Test.setMock(HttpCalloutMock.class, new MicrosoftGraphAPIMock());
        OutlookCalendarInvite.sendOutlookCalendarInvite(deadlineIds);
        Test.stopTest();
    }

    private static String getDepartmentByIndex(Integer index) {
        List<String> departments = new List<String>{
            'Finance',
            'Economic Mobility',
            'Human Resources',
            'Executive Team',
            'Property Management',
            'Resource Development'
        };
        return departments[Math.mod(index, departments.size())];
    }
}


OutlookCalendarEvent

public class OutlookCalendarEvent {
    public String subject;
    public Body body;
    public DateTimeTimeZone startDateTimeZone;
    public DateTimeTimeZone endDateTimeZone;
    public Boolean isAllDay;

    public class Body {
        public String contentType;
        public String content;

        public Body(String content, String contentType) {
            this.content = content;
            this.contentType = contentType;
        }
    }

    public class DateTimeTimeZone {
        public String dateTimeValue;
        public String timeZone;

        public DateTimeTimeZone(DateTime dateTimeValue, String timeZone) {
            this.dateTimeValue = dateTimeValue.format('yyyy-MM-dd\'T\'HH:mm:ss');
            this.timeZone = timeZone;
        }
    }
}
OutlookCalendarInviteMock
@isTest
global class OutlookCalendarInviteMock implements HttpCalloutMock {
    global HttpResponse respond(HttpRequest request) {
        HttpResponse response = new HttpResponse();
        response.setStatusCode(201); // Assuming successful creation of the calendar event
        response.setBody('{}'); // Set an empty JSON object as the body
        return response;
    }
}

MicrosoftGraphAPI
 
public class MicrosoftGraphAPI {
    private static final String CLIENT_ID = 'myclientid';
    private static final String CLIENT_SECRET = 'myclientsecret';
    private static final String TENANT_ID = 'mytenantid';
    public static final String MICROSOFTGRAPHENDPOINT = 'https://graph.microsoft.com';

    public class OAuth2 {
        public String token_type {get; set;}
        public String expires_in {get; set;}
        public String ext_expires_in {get; set;}
        public String access_token {get; set;}
    }

    public static OAuth2 getAccessToken() {
        String tokenEndpoint = 'https://login.microsoftonline.com/' + TENANT_ID + '/oauth2/token';

        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint(tokenEndpoint);
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');

        String body = 'grant_type=client_credentials' +
                      '&client_id=' + CLIENT_ID +
                      '&client_secret=' + CLIENT_SECRET +
                      '&resource=https://graph.microsoft.com';
        req.setBody(body);

        Http http = new Http();
        HttpResponse res = http.send(req);

        if (res.getStatusCode() == 200) {
            return (OAuth2) JSON.deserialize(res.getBody(), OAuth2.class);
        } else {
            return null;
        }
    }
}
MicrosoftGraphAPIMock
@isTest
global class MicrosoftGraphAPIMock implements HttpCalloutMock {
    global HttpResponse respond(HttpRequest req) {
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');

        if (req.getEndpoint().contains('/oauth2/v2.0/token')) {
            res.setStatusCode(200);
            String responseBody = '{"token_type": "Bearer", "expires_in": "3599", "ext_expires_in": "3599", "access_token": "mock_access_token"}';
            res.setBody(responseBody);
        } else if (req.getEndpoint().contains('/v1.0/me/calendars/')) {
            res.setStatusCode(201);
            String responseBody = '{"id": "mock_event_id", "subject": "mock_subject", "start": {"dateTime": "2023-05-05T00:00:00.000Z", "timeZone": "UTC"}, "end": {"dateTime": "2023-05-06T00:00:00.000Z", "timeZone": "UTC"}}';
            res.setBody(responseBody);
        }
        
        return res;
    }
}
GrantDeadlineTrigger
 
trigger GrantDeadlineTrigger on npsp__Grant_Deadline__c (after insert, after update) {
    List<npsp__Grant_Deadline__c> deadlinesToNotify = new List<npsp__Grant_Deadline__c>();

    for (npsp__Grant_Deadline__c deadline : Trigger.new) {
        if (deadline.npsp__Type__c == 'Final Report' && deadline.Email_Sent__c == false) {
            deadlinesToNotify.add(deadline);
        }
    }

    if (!deadlinesToNotify.isEmpty()) {
        System.enqueueJob(new OutlookCalendarInvite(deadlinesToNotify));
    }
}

 

Hello All, 

I'm trying to automatically send a PDFPage as an attachment every time a new grant opportunity is created or StageName == 'Vetting'. 

The following is my ApexTrigger. 

trigger SendPDFOpportunity on Opportunity (after insert, after update) {
  // Check if the opportunity is newly created or marked as vetting
  for (Opportunity opp : Trigger.new) {
    if ((opp.IsClosed && opp.IsWon) || opp.StageName == 'Vetting') {
      // Send the PDF as an attachment
      sendPdfAsAttachment(opp.Id);
    }
  }
}

private void sendPdfAsAttachment(Id opportunityId) {
  // Generate the PDF
  PageReference pdfPage = Page.NewGrantOpportunity;
  pdfPage.getParameters().put('id', opportunityId);
  Blob pdfBlob = pdfPage.getContent();

  // Create the attachment
  Attachment pdfAttachment = new Attachment();
  pdfAttachment.Name = 'Opportunity.Name + '.pdf';
  pdfAttachment.Body = pdfBlob;
  pdfAttachment.ContentType = 'application/pdf';
  pdfAttachment.ParentId = opportunityId;
  insert pdfAttachment;
}

It is currently showing errors in line 6 and 11. 

Line 6: Method does not exist or incorrect signature: void sendPdfAsAttachment(Id) from the type SendPDFOpportunity

Line 11: Missing '<EOF>' at 'private'

I have been trying everything I could. Any recommendations for me? 

 

Hello All, 

I created an ApexPage and an ApexTrigger. 

The ApexPage takes information from the Opportunity Object to create a PDF. That PDF should be automatically sent to an email every time the opportunity Stage is marked as "Vetting". 

The code for my ApexPage named "NewGrantOpportunity" is not converting heading 2 (H2) into bold. What I'm doing wrong?

ApexPage Code: 

<apex:page standardController="Opportunity" renderAs="pdf">
  <head>
    <style>
    .bold {
      font-weight: bold;
    }
    </style>
  </head>

  <h1>New Grant Opportunity</h1>
  <h2>Funding Opportunity Detail</h2>
  <br />
  <apex:outputLabel value="Opportunity ID: " for="opportunityId" styleClass="bold"/>
  <apex:outputField id="opportunityId" value="{!Opportunity.Id}"/>
  <br />
  <apex:outputLabel value="Opportunity Name: " for="opportunityName" styleClass="bold"/>
  <apex:outputField id="opportunityName" value="{!Opportunity.Name}"/>
  <br />
  <apex:outputLabel value="Description: " for="description" styleClass="bold"/>
  <apex:outputField id="description" value="{!Opportunity.RecordType.Description}"/>
  <br />
  <apex:outputLabel value="Notification Date: " for="notificationDate" styleClass="bold"/>
  <apex:outputField id="notificationDate" value="{!Opportunity.Notification_Date__c}"/>
  <br />
  <apex:outputLabel value="Deadline (Close Date): " for="closeDate" styleClass="bold"/>
  <apex:outputField id="closeDate" value="{!Opportunity.CloseDate}"/>
  <br />
  <apex:outputLabel value="Funding Area: " for="fundingArea" styleClass="bold"/>
  <apex:outputField id="fundingArea" value="{!Opportunity.npsp__Grant_Program_Area_s__c}"/>
  <br />
  <apex:outputLabel value="Award Amount: " for="awardAmount" styleClass="bold"/>
  <apex:outputField id="awardAmount" value="{!Opportunity.Award_Amount__c}"/>
  <br />
  <h2>Account Information</h2>
  <apex:outputLabel value="Funder Name: " for="funderName" styleClass="bold"/>
  <apex:outputField id="funderName" value="{!Opportunity.Account.Name}"/>
  <br />
  <apex:outputLabel value="Funder Area: " for="funderArea" styleClass="bold"/>
  <apex:outputField id="funderArea" value="{!Opportunity.Programs__c}"/>
  <br />
  <apex:outputLabel value="Type: " for="type" styleClass="bold"/>
  <apex:outputField id="type" value="{!Opportunity.Account.Type}"/>
  <br />
  <apex:outputLabel value="Primary Contact: " for="primaryContact" styleClass="bold"/>
  <apex:outputField id="primaryContact" value="{!Opportunity.npsp__Primary_Contact__r.Name}"/>
  <br />
  <apex:outputLabel value="Website: " for="website" styleClass="bold"/>
  <apex:outputField id="website" value="{!Opportunity.npsp__Grant_Requirements_Website__c}" />
  <br />
  <h2>Program Design and Budget Information</h2>
  <apex:outputLabel value="Grant Eligibility: " for="grantEligibility" styleClass="bold"/> 
  <apex:outputField id="grantEligibility" value="{!Opportunity.Grant_Eligibility__c}"/>
  <br />
  <apex:outputLabel value="Program Goals: " for="programGoals" styleClass="bold"/> 
  <apex:outputField id="programGoals" value="{!Opportunity.Grant_Goals__c}"/>
  <br />
  <apex:outputLabel value="Use of Funds: " for="useOfFunds" styleClass="bold"/> 
  <apex:outputField id="useOfFunds" value="{!Opportunity.Use_of_Funds__c}"/>
  <br />
  <h2>Strategic Information</h2>
  <apex:outputLabel value="Funding Source: " for="fundingSource" styleClass="bold"/>   
  <apex:outputField id="fundingSource" value="{!Opportunity.Funding_Source__c}"/>
  <br />
  <apex:outputLabel value="Strategic Alignment: " for="strategicAlignment" styleClass="bold"/>   
  <apex:outputField id="strategicAlignment" value="{!Opportunity.Strategic_Alignment__c}"/>
  <br />
  <apex:outputLabel value="Fiscal Year: " for="fiscalYear" styleClass="bold"/> 
  <apex:outputField id="fiscalYear" value="{!Opportunity.Fiscal_Year__c}"/>
  <br />
  <apex:outputLabel value="Stage: " for="Stage" styleClass="bold"/> 
  <apex:outputField id="Stage" value="{!Opportunity.StageName}"/>
  <br />
  <h2>Vetting Process</h2>
  <apex:outputLabel value="Select the checkmark if the opportunity was reviewed and was approved as prospecting: " for="vetted" styleClass="bold"/>   
  <apex:outputField id="vetted" value="{!Opportunity.Vetted_Grant__c}"/>
</apex:page>

Similarly, my ApexTrigger named "PDFGenerator" is not generating an automatic email. 

ApexTrigger Code: 
 

public class PDFGenerator {
  public static void sendPDF(Id opportunityId) {
    // Query the opportunity record
    Opportunity opportunity = [SELECT Id, Name FROM Opportunity WHERE Id = :opportunityId];

    // Generate the PDF attachment
    PageReference pdf = Page.NewGrantOpportunity;
    pdf.getParameters().put('id', opportunity.Id);
    Blob pdfBlob = pdf.getContentAsPDF();
    String fileName = opportunity.Name + '.pdf';
    Messaging.EmailFileAttachment pdfAttachment = new Messaging.EmailFileAttachment();
    pdfAttachment.setFileName(fileName);
    pdfAttachment.setBody(pdfBlob);

    // Set up the email message
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    email.setToAddresses(new String[] {'grants@EXAMPLE.org'});
    email.setSubject('New Grant Opportunity PDF: {!relatedTo.Name}');
    email.setPlainTextBody('A new opportunity was created with the name {!Opportunity.Name}.');
    email.setTemplateId('00EXAMPLEiEAG');
    email.setTargetObjectId(opportunity.Id);  
    email.setFileAttachments(new Messaging.EmailFileAttachment[] { pdfAttachment });

    // Send the email
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
  }
}
I appreciate your help in advance. 

 

Hello All, 

I want to find a way to create a task automatically when a deliverable is created. Specifically, I create a deliverable named Final Year Report. That deliverable include all the requirements, deadline, person responsible, and others. I want to be able to create a process builder or a trigger that allow me to do two things at the same time. 

First, send a email notification to the person responsible indicating that a new deliverable was created. At the same time, I want that automatically a task with the information gets created in the system. 
Here is my proces. 

User-added image I would like to add as an action the creation of a task. 

Is that possible? Any reccomendations?
Hello All, 
I need to fix the following formulas on Salesforce. The current formulas work, but they are marking an error when the fields are empty. All the formulas are created as "treat blank fields as blanks". In this specific object on my system, blanck field means that do not apply.  

First Formula:
This formula calculate a percent between 4 fields. It give me a yearl result. 
IF(
AND
(Q1_c__c =0,
Q2_c__c = 0,
Q3_c__c = 0,
Q4_c__c = 0
),
0,
(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

The problem with the formula is that does not work if the Q1_c__c, Q2_c__c, Q3_c__c, or Q4_c__c,are blanks. If those fields are blank, the formula do not calculate the percentage. 

Second Formula
This formula automatically add flags according to the value of certain fields.
  
(
IF( ISBLANK(Q1_Goal__c ) && ISBLANK(Q1_Value__c ),
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),

IF(NOT(ISBLANK(Q1_Goal__c )) && ISBLANK(Q1_Value__c ) ,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),

IF(ISBLANK(Q1_c__c ),
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),

IF (Q1_c__c <= 0.80,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),

IF (Q1_c__c <= 0.90,
IMAGE("https://i.ibb.co/59L8GnF/yellow-flag.png", " Yellow Flag"),
IMAGE("https://i.ibb.co/1KNswzk/green-flag.png", " Green Flag")))))))

The problem with the formula second formula  is that the second IF is not working. 

IF(NOT(ISBLANK(Q1_Goal__c )) && ISBLANK(Q1_Value__c ) ,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),


It suppsed that when Q1_Goal__c  is NOT blank (not empty) and Q1_Value__c is empty create a RED Flag. Currently is not doing that. 

Any suggestions with the formulas. 

Thank you, 

Felix. 
Hi everyone, 

I have eight custom fields that needs to be restrict from being edited after specific dates for all users except sys_admin and executive. Specifically: 
  • Four of those fields (q1_goal, q2_goal, q3_goal, and q4_goal) needs to be block after November 15 of every year. 
  • The other four (q1_value, q2_value, q3_value, and q4_value) needs to be block in different times. 
    • q1_value should be block after January 15.
    • q2_value should be block after April 15
    • q3_value should be block after July 15
    • q4_value should be block after Nobember 15.
Anyone cal help? 
Thank you. 
Hello All, 
I'm trying to fix the following formulas that are showing an error when the value is left blank. In our object, black field are important because means that they do not apply. The fields that are showing an error are Q1 Results and Q1 Flag. 

Field: Q1 Results
IF(
ISNULL( Q1_Validation__c ),
NULL,
Q1_Value__c / Q1_Goal__c
)

Field: Q1 Validation
IF(
AND(ISBLANK(Q1_Goal__c ),ISBLANK(Q1_Value__c )),
NULL,1)

Field: Q1 Flag
(
IF( ISBLANK(Q1_Goal__c ) && ISBLANK(Q1_Value__c ),
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),

IF(ISBLANK(Q1_c__c ),
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),

IF (Q1_c__c <= 0.80,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),

IF (Q1_c__c <= 0.90,
IMAGE("https://i.ibb.co/59L8GnF/yellow-flag.png", " Yellow Flag"),
IMAGE("https://i.ibb.co/1KNswzk/green-flag.png", " Green Flag"))))))

I appreciate all your help. 

 

Hello All, 

I'm trying to create a formula field (Yearly Compliance) for a custom object named Compliance. The formula should add the compliance for the quarter (i.e. Q1_c__c), if not left blankand, and divide those by the number of complete fields. I'm trying to calculate the percent of compliance. The problem is that any of those four number fields could be left on black.

I tried the following formulas in where any of the Qs (i.e. Q1_c__c)  could be a number or could be left blank.

IF( 
AND 
   (Q1_c__c =0, 
    Q1_c__c = 0, 
    Q1_c__c = 0, 
   Q1_c__c = 0
    ),
    0, 
(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

 

IF(

AND(
ISBLANK(Q1_c__c),
ISBLANK(Q2_c__c),
ISBLANK(Q3_c__c),
ISBLANK(Q4_c__c)
),
NULL,(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

Here is a picture of the pay layout . 

  • If the quarter is left black, means that do not apply.
  • I'm trying to calculate the percent of Yearly Compliance. Here the Yearly Compliance should be 100% divided by 3. This is because the quarter empty (Q1) do not count for this year compliance. Also, the other two quarters are in 0%. 


Example
 

Yearly compliance should be 33.33%
Hello All, 
We were using NSPS in production without a Sandbox for over a year. Now, I create a Sandbox to configure Program Management Module (PMM). Can I deploy PMM to production without affecting NSPS? Production already have lots of information in NSPS. 
Thanks in advance. 

 

Hello All, 

I'm trying to create a formula for a compliance field (variable). The field could have values or not. If the field has values (Not Blank), I need that the field make a division (Q1_Value__c / Q1_Goal__c). If there is no values, I need the fielf diplay "N/A" or stay blanck. 

Something like the following: 

IF (OR
(NOT(ISBLANK(Q1_Goal__c)),
Q1_Value__c / Q1_Goal__c),
ISBLANK(Q1_Goal__c), "N/A"))

Thanks in advance. 

Hello All, 

I'm realatively new to salesforce and I'm trying to develop a formula that respond with an image to the result of another formula. The current formula worked, except when the result of the original formula is 0.00 or blank. 

Specifically, the formula below is looking for the result of Q1_c_c (Compliance for Quarter 1). I want a blue flag if there is a 0.00 (we are not measuring that quarter) or no information or result. 

IF (Q1_c__c <= 0.01,
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),
IF (Q1_c__c <= 0.80,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),
IF (Q1_c__c <= 0.90,
IMAGE("https://i.ibb.co/59L8GnF/yellow-flag.png", " Yellow Flag"),
IMAGE("https://i.ibb.co/1KNswzk/green-flag.png", " Green Flag"))))

I will appreciate the help. 

Hello All, 

I'm trying to create a formula field (Yearly Compliance) for a custom object named Compliance. The formula should add the compliance for the quarter (i.e. Q1_c__c), if not left blankand, and divide those by the number of complete fields. I'm trying to calculate the percent of compliance. The problem is that any of those four number fields could be left on black.

I tried the following formulas in where any of the Qs (i.e. Q1_c__c)  could be a number or could be left blank.

IF( 
AND 
   (Q1_c__c =0, 
    Q1_c__c = 0, 
    Q1_c__c = 0, 
   Q1_c__c = 0
    ),
    0, 
(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

 

IF(

AND(
ISBLANK(Q1_c__c),
ISBLANK(Q2_c__c),
ISBLANK(Q3_c__c),
ISBLANK(Q4_c__c)
),
NULL,(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

Here is a picture of the pay layout . 

  • If the quarter is left black, means that do not apply.
  • I'm trying to calculate the percent of Yearly Compliance. Here the Yearly Compliance should be 100% divided by 3. This is because the quarter empty (Q1) do not count for this year compliance. Also, the other two quarters are in 0%. 


Example
 

Yearly compliance should be 33.33%

Hello All, 

I'm trying to automatically send a PDFPage as an attachment every time a new grant opportunity is created or StageName == 'Vetting'. 

The following is my ApexTrigger. 

trigger SendPDFOpportunity on Opportunity (after insert, after update) {
  // Check if the opportunity is newly created or marked as vetting
  for (Opportunity opp : Trigger.new) {
    if ((opp.IsClosed && opp.IsWon) || opp.StageName == 'Vetting') {
      // Send the PDF as an attachment
      sendPdfAsAttachment(opp.Id);
    }
  }
}

private void sendPdfAsAttachment(Id opportunityId) {
  // Generate the PDF
  PageReference pdfPage = Page.NewGrantOpportunity;
  pdfPage.getParameters().put('id', opportunityId);
  Blob pdfBlob = pdfPage.getContent();

  // Create the attachment
  Attachment pdfAttachment = new Attachment();
  pdfAttachment.Name = 'Opportunity.Name + '.pdf';
  pdfAttachment.Body = pdfBlob;
  pdfAttachment.ContentType = 'application/pdf';
  pdfAttachment.ParentId = opportunityId;
  insert pdfAttachment;
}

It is currently showing errors in line 6 and 11. 

Line 6: Method does not exist or incorrect signature: void sendPdfAsAttachment(Id) from the type SendPDFOpportunity

Line 11: Missing '<EOF>' at 'private'

I have been trying everything I could. Any recommendations for me? 

 

Hello All, 

I created an ApexPage and an ApexTrigger. 

The ApexPage takes information from the Opportunity Object to create a PDF. That PDF should be automatically sent to an email every time the opportunity Stage is marked as "Vetting". 

The code for my ApexPage named "NewGrantOpportunity" is not converting heading 2 (H2) into bold. What I'm doing wrong?

ApexPage Code: 

<apex:page standardController="Opportunity" renderAs="pdf">
  <head>
    <style>
    .bold {
      font-weight: bold;
    }
    </style>
  </head>

  <h1>New Grant Opportunity</h1>
  <h2>Funding Opportunity Detail</h2>
  <br />
  <apex:outputLabel value="Opportunity ID: " for="opportunityId" styleClass="bold"/>
  <apex:outputField id="opportunityId" value="{!Opportunity.Id}"/>
  <br />
  <apex:outputLabel value="Opportunity Name: " for="opportunityName" styleClass="bold"/>
  <apex:outputField id="opportunityName" value="{!Opportunity.Name}"/>
  <br />
  <apex:outputLabel value="Description: " for="description" styleClass="bold"/>
  <apex:outputField id="description" value="{!Opportunity.RecordType.Description}"/>
  <br />
  <apex:outputLabel value="Notification Date: " for="notificationDate" styleClass="bold"/>
  <apex:outputField id="notificationDate" value="{!Opportunity.Notification_Date__c}"/>
  <br />
  <apex:outputLabel value="Deadline (Close Date): " for="closeDate" styleClass="bold"/>
  <apex:outputField id="closeDate" value="{!Opportunity.CloseDate}"/>
  <br />
  <apex:outputLabel value="Funding Area: " for="fundingArea" styleClass="bold"/>
  <apex:outputField id="fundingArea" value="{!Opportunity.npsp__Grant_Program_Area_s__c}"/>
  <br />
  <apex:outputLabel value="Award Amount: " for="awardAmount" styleClass="bold"/>
  <apex:outputField id="awardAmount" value="{!Opportunity.Award_Amount__c}"/>
  <br />
  <h2>Account Information</h2>
  <apex:outputLabel value="Funder Name: " for="funderName" styleClass="bold"/>
  <apex:outputField id="funderName" value="{!Opportunity.Account.Name}"/>
  <br />
  <apex:outputLabel value="Funder Area: " for="funderArea" styleClass="bold"/>
  <apex:outputField id="funderArea" value="{!Opportunity.Programs__c}"/>
  <br />
  <apex:outputLabel value="Type: " for="type" styleClass="bold"/>
  <apex:outputField id="type" value="{!Opportunity.Account.Type}"/>
  <br />
  <apex:outputLabel value="Primary Contact: " for="primaryContact" styleClass="bold"/>
  <apex:outputField id="primaryContact" value="{!Opportunity.npsp__Primary_Contact__r.Name}"/>
  <br />
  <apex:outputLabel value="Website: " for="website" styleClass="bold"/>
  <apex:outputField id="website" value="{!Opportunity.npsp__Grant_Requirements_Website__c}" />
  <br />
  <h2>Program Design and Budget Information</h2>
  <apex:outputLabel value="Grant Eligibility: " for="grantEligibility" styleClass="bold"/> 
  <apex:outputField id="grantEligibility" value="{!Opportunity.Grant_Eligibility__c}"/>
  <br />
  <apex:outputLabel value="Program Goals: " for="programGoals" styleClass="bold"/> 
  <apex:outputField id="programGoals" value="{!Opportunity.Grant_Goals__c}"/>
  <br />
  <apex:outputLabel value="Use of Funds: " for="useOfFunds" styleClass="bold"/> 
  <apex:outputField id="useOfFunds" value="{!Opportunity.Use_of_Funds__c}"/>
  <br />
  <h2>Strategic Information</h2>
  <apex:outputLabel value="Funding Source: " for="fundingSource" styleClass="bold"/>   
  <apex:outputField id="fundingSource" value="{!Opportunity.Funding_Source__c}"/>
  <br />
  <apex:outputLabel value="Strategic Alignment: " for="strategicAlignment" styleClass="bold"/>   
  <apex:outputField id="strategicAlignment" value="{!Opportunity.Strategic_Alignment__c}"/>
  <br />
  <apex:outputLabel value="Fiscal Year: " for="fiscalYear" styleClass="bold"/> 
  <apex:outputField id="fiscalYear" value="{!Opportunity.Fiscal_Year__c}"/>
  <br />
  <apex:outputLabel value="Stage: " for="Stage" styleClass="bold"/> 
  <apex:outputField id="Stage" value="{!Opportunity.StageName}"/>
  <br />
  <h2>Vetting Process</h2>
  <apex:outputLabel value="Select the checkmark if the opportunity was reviewed and was approved as prospecting: " for="vetted" styleClass="bold"/>   
  <apex:outputField id="vetted" value="{!Opportunity.Vetted_Grant__c}"/>
</apex:page>

Similarly, my ApexTrigger named "PDFGenerator" is not generating an automatic email. 

ApexTrigger Code: 
 

public class PDFGenerator {
  public static void sendPDF(Id opportunityId) {
    // Query the opportunity record
    Opportunity opportunity = [SELECT Id, Name FROM Opportunity WHERE Id = :opportunityId];

    // Generate the PDF attachment
    PageReference pdf = Page.NewGrantOpportunity;
    pdf.getParameters().put('id', opportunity.Id);
    Blob pdfBlob = pdf.getContentAsPDF();
    String fileName = opportunity.Name + '.pdf';
    Messaging.EmailFileAttachment pdfAttachment = new Messaging.EmailFileAttachment();
    pdfAttachment.setFileName(fileName);
    pdfAttachment.setBody(pdfBlob);

    // Set up the email message
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    email.setToAddresses(new String[] {'grants@EXAMPLE.org'});
    email.setSubject('New Grant Opportunity PDF: {!relatedTo.Name}');
    email.setPlainTextBody('A new opportunity was created with the name {!Opportunity.Name}.');
    email.setTemplateId('00EXAMPLEiEAG');
    email.setTargetObjectId(opportunity.Id);  
    email.setFileAttachments(new Messaging.EmailFileAttachment[] { pdfAttachment });

    // Send the email
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
  }
}
I appreciate your help in advance. 

 

Hi everyone, 

I have eight custom fields that needs to be restrict from being edited after specific dates for all users except sys_admin and executive. Specifically: 
  • Four of those fields (q1_goal, q2_goal, q3_goal, and q4_goal) needs to be block after November 15 of every year. 
  • The other four (q1_value, q2_value, q3_value, and q4_value) needs to be block in different times. 
    • q1_value should be block after January 15.
    • q2_value should be block after April 15
    • q3_value should be block after July 15
    • q4_value should be block after Nobember 15.
Anyone cal help? 
Thank you. 
Hello All, 
I'm trying to fix the following formulas that are showing an error when the value is left blank. In our object, black field are important because means that they do not apply. The fields that are showing an error are Q1 Results and Q1 Flag. 

Field: Q1 Results
IF(
ISNULL( Q1_Validation__c ),
NULL,
Q1_Value__c / Q1_Goal__c
)

Field: Q1 Validation
IF(
AND(ISBLANK(Q1_Goal__c ),ISBLANK(Q1_Value__c )),
NULL,1)

Field: Q1 Flag
(
IF( ISBLANK(Q1_Goal__c ) && ISBLANK(Q1_Value__c ),
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),

IF(ISBLANK(Q1_c__c ),
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),

IF (Q1_c__c <= 0.80,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),

IF (Q1_c__c <= 0.90,
IMAGE("https://i.ibb.co/59L8GnF/yellow-flag.png", " Yellow Flag"),
IMAGE("https://i.ibb.co/1KNswzk/green-flag.png", " Green Flag"))))))

I appreciate all your help. 

 

Hello All, 

I'm trying to create a formula field (Yearly Compliance) for a custom object named Compliance. The formula should add the compliance for the quarter (i.e. Q1_c__c), if not left blankand, and divide those by the number of complete fields. I'm trying to calculate the percent of compliance. The problem is that any of those four number fields could be left on black.

I tried the following formulas in where any of the Qs (i.e. Q1_c__c)  could be a number or could be left blank.

IF( 
AND 
   (Q1_c__c =0, 
    Q1_c__c = 0, 
    Q1_c__c = 0, 
   Q1_c__c = 0
    ),
    0, 
(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

 

IF(

AND(
ISBLANK(Q1_c__c),
ISBLANK(Q2_c__c),
ISBLANK(Q3_c__c),
ISBLANK(Q4_c__c)
),
NULL,(Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/4)

Here is a picture of the pay layout . 

  • If the quarter is left black, means that do not apply.
  • I'm trying to calculate the percent of Yearly Compliance. Here the Yearly Compliance should be 100% divided by 3. This is because the quarter empty (Q1) do not count for this year compliance. Also, the other two quarters are in 0%. 


Example
 

Yearly compliance should be 33.33%

Hello All, 

I'm trying to create a formula for a compliance field (variable). The field could have values or not. If the field has values (Not Blank), I need that the field make a division (Q1_Value__c / Q1_Goal__c). If there is no values, I need the fielf diplay "N/A" or stay blanck. 

Something like the following: 

IF (OR
(NOT(ISBLANK(Q1_Goal__c)),
Q1_Value__c / Q1_Goal__c),
ISBLANK(Q1_Goal__c), "N/A"))

Thanks in advance. 

Hello All, 

I'm realatively new to salesforce and I'm trying to develop a formula that respond with an image to the result of another formula. The current formula worked, except when the result of the original formula is 0.00 or blank. 

Specifically, the formula below is looking for the result of Q1_c_c (Compliance for Quarter 1). I want a blue flag if there is a 0.00 (we are not measuring that quarter) or no information or result. 

IF (Q1_c__c <= 0.01,
IMAGE("https://i.ibb.co/PzwzmbZ/blue-flag.png", " Blue Flag"),
IF (Q1_c__c <= 0.80,
IMAGE("https://i.ibb.co/02GzKqM/red-flag.png", " Red Flag"),
IF (Q1_c__c <= 0.90,
IMAGE("https://i.ibb.co/59L8GnF/yellow-flag.png", " Yellow Flag"),
IMAGE("https://i.ibb.co/1KNswzk/green-flag.png", " Green Flag"))))

I will appreciate the help.