• Dedeepya Munjuluri
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,

I need to create a lightning community using Napili template. The entire content of the community is categorized into 5 menu items which is the first level of menu section. Under each menu item, there will be few sub menu items like a parent - child. For each navigation path that lands at a child, should redirect to an url of the company. I tried all the options possible with community builder, but could not configure the way to set up second and third level of menu items. Can someone guide me how to achieve this?

Please let me know if anything is not clear.

Appreciate your help!!!

Thanks,
Dedeepya.
I am trying to understand how to set up the Named Credentials & OAuth Provider in Salesforce for calling the External REST API. Before setting this up I tested the call to the REST API through Apex like and it works fine
public class TestD365API {
    public final String clientId = 'xxxxxxx';
    public final String clientSecret = 'xxxxxx';
    public final String tenant_id = 'xxxx';
    public final String resource = 'https://abc.dynamics.com';

    public String getD365Customer(){             
        String reqbody = 'grant_type=client_credentials&client_id='+clientId+'&client_secret='+clientSecret+'&tenant_id='+tenant_id+'&resource='+resource;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setBody(reqbody);
        req.setMethod('POST');
        req.setEndpoint('https://login.microsoftonline.com/tenant/oauth2/token');
        HttpResponse res = h.send(req);
        deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
        String atoken = resp1.access_token;
        System.debug('Access Token=========' + atoken);

        Http http1 = new Http();
        HttpRequest req1 = new HttpRequest();
        req1.setEndpoint('https://abc.dynamics.com/data/Customers');
        req1.setMethod('GET');
        req1.setHeader('Authorization','Bearer '+atoken);
        HttpResponse res1 = http1.send(req1);
        System.debug('Response Body=========' + res1.getBody());
        return res1.getBody();                
    }  

    public class deserializeResponse
    {
        public String token_type;
        public String expires_in;
        public String ext_expires_in;
        public String expires_on;
        public String not_before;
        public String resource;
        public String access_token;
    }
}


I am passing 5 parameters in the request body to get the bearer token from the Authorization Provider and passing the token to the Rest endpoint and retrieving the data back.
Now trying to use Named credentials instead like below
User-added image
where in the Authorize URL I am giving as https://login.microsoftonline.com/tenant/oauth2/authorize?grant_type=client_credentials&tenant_id=xxxxxxxxxxx
And changed my Apex Code like
User-added imageI am not sure how to pass all the parameters (grant_type,tenant_id, client_id,client_secret,resource) to the Auth Provider and the bearer token to the Rest API endpoint through Named Credentials and get the response back. I am sure this is not the firewall/issue on Client end as I am able to test it through Apex Code. Any help is appreciated
  • February 14, 2020
  • Like
  • 0
Hi ,
I am trying to send a meeting invitation from salesforce to outlook or Gmail with meeting date and time. I have a code to do this, but it is hardcoded. I need to send the meeting invitation with date and time as mentioned by the user.

Here is the code:-
Vf page:-

<apex:page controller="SendEmail">
    <apex:form >
        <apex:pageblock >
            <apex:pageblocksection columns="2">
                <apex:outputText value="Email"/><br/>
                <apex:inputText value="{!sendTo}"/><br/>
                <apex:outputText value="Subject"/><br/>
                <apex:inputText value="{!subject}" maxlength="80"/><br/>
                <apex:inputField value="{!objEvent.ActivityDate}" /><br/>
                <apex:inputField value="{!objEvent.StartDateTime}" /><br/>
                <apex:inputField value="{!objEvent.Description}" /><br/>
                <apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($CurrentPage.parameters.start,':',''),'-',''),' ','T')}"/>
            </apex:pageblocksection>
        </apex:pageblock>
        
             <!---   <apex:inputField value="{!objEvent.starttime}" /> -->
                <apex:commandButton value="send" action="{!sendInvite}"/>
    </apex:form>
</apex:page>

Controller:-

public class SendEmail {
    public String sendTo { get; set; }
    public String Subject { get; set; }
    public Event objEvent{get;set;}
    public SendEmail() {}
    public PageReference sendInvite() {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {sendTo};
        mail.setToAddresses(toAddresses);
        mail.setSubject(Subject);
        mail.setPlainTextBody('');
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.filename = 'meeting.ics';
        attach.ContentType = 'text/calendar;';
        attach.inline = true;
        attach.body = invite();
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] {attach});
        Messaging.SendEmailResult[] er = Messaging.sendEmail(new Messaging.Email[] {mail});
        return null;
    }
    private Blob invite() {
        String txtInvite = '';
 
        txtInvite += 'BEGIN:VCALENDAR\n';
        txtInvite += 'PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\n';
        txtInvite += 'VERSION:2.0\n';
        txtInvite += 'METHOD:PUBLISH\n';
        txtInvite += 'X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n';
        txtInvite += 'BEGIN:VEVENT\n';
        txtInvite += 'CLASS:PUBLIC\n';
        txtInvite += 'CREATED:20150709T083709Z\n';
        txtInvite += 'DTEND:20150709T010000Z\n';
        txtInvite += 'DTSTAMP:20150708T203709Z\n';
        txtInvite += 'DTSTART:20150709T000000Z\n';
        txtInvite += 'LAST-MODIFIED:20150708T203709Z\n';
        txtInvite += 'LOCATION:Online\n';
        txtInvite += 'PRIORITY:5\n';
        txtInvite += 'SEQUENCE:0\n';
        txtInvite += 'SUMMARY;';
        txtInvite += 'LANGUAGE=en-us:Meeting\n';
        txtInvite += 'TRANSP:OPAQUE\n';
        txtInvite += 'UID:4036587160834EA4AE7848CBD028D1D200000000000000000000000000000000\n';
        txtInvite += 'X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><META NAME="Generator" CONTENT="MS Exchange Server version 08.00.0681.000"><TITLE></TITLE></HEAD><BODY><!-- Converted from text/plain format --></BODY></HTML>\n';
        txtInvite += 'X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n';
        txtInvite += 'X-MICROSOFT-CDO-IMPORTANCE:1\n';
        txtInvite += 'END:VEVENT\n';
        txtInvite += 'END:VCALENDAR';
 
        return Blob.valueOf(txtInvite);
    }
}