• Priyank Saklani 10
  • NEWBIE
  • 15 Points
  • Member since 2020

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

As an admin, I can send reset password emails to community users (As shown below)

Reset password email

But we want to send the reset password link to our community user via SMS (We have integration with NEXMO for sending out an SMS). How can I generate the Reset password link-only, so I can append it in the SMS content?

Hi All,

I am trying to convert a PHP code for rest callout into apex but having some troubles.
The PHP code is as follows:
 

$ch = curl_init();

//Set the URL to work with
curl_setopt($ch, CURLOPT_URL, $loginUrl);

// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);

//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, 'methodname=**NAME**&username='.$username.'&password='.$password);

//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute the request (the login)
$store = curl_exec($ch);
$errors = curl_error($ch);
$response = curl_getinfo($ch, CURLINFO_HTTP_CODE);

fwrite($fh,PHP_EOL.$errors);
fwrite($fh,PHP_EOL.$response);


//the login is now done and you can continue to get the
//protected content.

//set the URL to the protected file
curl_setopt($ch, CURLOPT_URL, 'EnqURL');
curl_setopt($ch, CURLOPT_REFERER, 'URL2');
curl_setopt($ch, CURLOPT_POSTFIELDS, '***Payload***');
$content = curl_exec($ch);

There are two callouts happening here 1st for login which is returning a session cookie that is being used in the 2nd callout to fetch the protected information. This piece of code is working fine in PHP.
For APEX I have written the following code:
 
public class Scraper {
    @future(callout=True)
    public static void Auth&Fetch(String username, String password) {
        string loginUrl= '***LoginURL***?methodname=**NAME**&username='+username+'&password='+password;
        HTTP h = new HTTP();
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setHeader('Content-Length', '0');
        req.setEndpoint(loginUrl);
        HttpResponse res = h.send(req);
        while (res.getStatusCode() == 302) {
            req.setEndpoint(res.getHeader('Location'));
            res = new Http().send(req);
        }
        System.debug('response: '+res.getBody());

        //Use the session cookie from auth here
        string cookie = res.getHeader('Set-Cookie');
        string IdForLookup= '12345678910';
        
        string EnqURL = 'EnqURL';
        string payload = '***Payload***';
        req.setEndpoint(EnqURL);
        req.setBody(payload); //Use IdForLookup Here
        req.setHeader('Cookie', cookie);
        req.setHeader('Content-Length', String.valueOf(payload.length()));
        
        HttpResponse res2 = h.send(req);
        System.debug('response Status: '+res2.getStatusCode());
        System.debug('response: '+res2.getBody());
    }
}

On the second callout, I am getting an error 'User not logged in'. But from command line CURL and POSTMAN I am able to retrieve the information. I think this is due to the way cookies are handled in the PHP vs APEX code. Any help will be appreciated.
I am trying to open a new community page on the click of a button. I am trying to pass the parameters needed for the lightning component on that page via the URL of the page:
Button Javascript Controller Code:
if(!$A.util.isUndefinedOrNull(ContactId)) {
    window.open('/lapv2/s/profile-detail/'+ ContactId + '?ApplicationId=' + ApplicationId+ '&propertyServiceId=' + propertyServiceId);
    }

Community Builder Page(Profile-detail):
profile-detail community builder pageCommunity Builder Page Configuration (Profile-detail):
profile-detail configThe component on the page is just displaying the parameters(TestComponent):
<aura:component access="global" controller="PB_ProfileDetailController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:LightningQuickActionWithoutHeader,forceCommunity:availableForAllPageTypes">
    
    
    <aura:attribute name="Debug" access="global" type="Boolean" default="true"/>
    
    <aura:attribute name="ContactId" type="String" access="global" />
    <aura:attribute name="ApplicationId" access="global" type="String" />
    <aura:attribute name="propertyServiceId" access="global" type="String"/>
    {!v.ContactId}
    {!v.ApplicationId}
    {!v.propertyServiceId}
</aura:component>

Design for the component(TestComponent):
<design:component>
    <design:attribute name="Debug" label="Debug"/>
    <design:attribute name="ContactId" label="cid"/>
    <design:attribute name="ApplicationId" />
    <design:attribute name="propertyServiceId" />
</design:component>

But on the click of the button, the page opens up in a new window just says 'invalid page':
Page not openingI can see the URL is as expected: https://salesforce-instance/s/profile-detail/0031x00000y7VNwAAM/detail?ApplicationId=a4c1x000000MuiZAAS&propertyServiceId=a4p1x00000093RKAAY but the page is not opening.

I created a new domain for our custom site because we wanted to use the custom URL for the community. After Domain creation I created a custom URL(for the site) and in the site, I assigned the new domain as the "preferred domain".

Domain created with the Custom URLsDue to mistakes in the configuration of the domain, the provisioning has Failed. Now I want to delete this domain and recreate the same domain with the correct configuration. But Since the custom URL is being used in the site it's not letting me delete the custom URL and the Domain.

How can I delink the custom URL from the site (I tried setting the previous domain as the preferred Domain but the custom URLs delete button is still disabled as seen in the above screenshot)?

As an admin, I can send reset password emails to community users (As shown below)

Reset password email

But we want to send the reset password link to our community user via SMS (We have integration with NEXMO for sending out an SMS). How can I generate the Reset password link-only, so I can append it in the SMS content?

As an admin, I can send reset password emails to community users (As shown below)

Reset password email

But we want to send the reset password link to our community user via SMS (We have integration with NEXMO for sending out an SMS). How can I generate the Reset password link-only, so I can append it in the SMS content?

I created a new domain for our custom site because we wanted to use the custom URL for the community. After Domain creation I created a custom URL(for the site) and in the site, I assigned the new domain as the "preferred domain".

Domain created with the Custom URLsDue to mistakes in the configuration of the domain, the provisioning has Failed. Now I want to delete this domain and recreate the same domain with the correct configuration. But Since the custom URL is being used in the site it's not letting me delete the custom URL and the Domain.

How can I delink the custom URL from the site (I tried setting the previous domain as the preferred Domain but the custom URLs delete button is still disabled as seen in the above screenshot)?