• Admin DNA
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 8
    Replies
Hi,
I try with this solution,
https://developer.salesforce.com/forums/?id=9060G0000005Pc1QAE
but It returns the ip ogf salesforce server. I want to get ip of client guest user of a ligghtning community.
Is there a solution?
Thankyou in advance
Hi, is there a way to get the ip address of the connected guest user?
I try the below code but it works for the logged user but returns null for the guest users:
@AuraEnabled   
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

I also try with a callout but it returns ip of salesforce server
 
Hi,
I receive this error " The list of results isn't the same size as the input list" when I run this class:
public static void findDuplicates() {
        Lead ld = new Lead(LastName='aaa', MobilePhone='11', Phone='11', Email='aaa@aaa.it', LeadSource='Passaparola');
        Lead ld1 = new Lead(LastName='aaa', MobilePhone='111', Phone='111', Email='aaa@aaa.it', LeadSource='Passaparola');
        List<Lead> leadList = new List<Lead>();
        leadList.add(ld);
        leadList.add(ld1);
        
        Datacloud.FindDuplicatesResult[] results = Datacloud.FindDuplicates.findDuplicates(leadList);
        for (Datacloud.FindDuplicatesResult findDupeResult : results) {
          for (Datacloud.DuplicateResult dupeResult : findDupeResult.getDuplicateResults()) {
            for (Datacloud.MatchResult matchResult : dupeResult.getMatchResults()) {
              for (Datacloud.MatchRecord matchRecord : matchResult.getMatchRecords()) {
                  System.debug('Duplicate Record: ' + matchRecord.getRecord());
              }
            }
          }
        }
Any Ideas?
thanks in advance
 
Hi, is there a way to get the ip address of the connected guest user?
I try the below code but it works for the logged user but returns null for the guest users:
view sourceprint?
@AuraEnabled   
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

 
Hi, is there a way to get the ip address of the connected guest user?
I try the below code but it works for the logged user but returns null for the guest users:
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

 
Hi,
I'm trying to test a class wher I get current User Ip
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

return ReturnValue;
} // GetUserIPAddress



Test class:

 public static testmethod void Test1()
 {System.runAs(new User(Id = UserInfo.getUserId())){
     
     String ip = siteLeadForm.GetUserIPAddress();}
       
        

    }

In sandbox it is ok, but in production I receive this error:
System.UnexpectedException: Current session unavailable 
Stack Trace: Class.Auth.SessionManagement.getCurrentSession: line 5, column 1 Class.siteLeadForm.GetUserIPAddress: line 18, column 1 Class.siteLeadFormTEST.Test1: line 17, column 1


Any Ideas?
thankyou in advance
Hi,
i'm trying to get ip address of the client in a lightning component in a community but i receive Server error.
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = '';
ReturnValue = ApexPages.currentPage().getHeaders().get('True-Client-IP');
if (ReturnValue == '') {
ReturnValue = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
} // get IP address when no caching (sandbox, dev, secure urls)
system.debug('USER IP ADDRESS: ' + ReturnValue);
return ReturnValue;
} // GetUserIPAddress

Any Ideas?
This is the class:
public without sharing class calculatorController {
@AuraEnabled
public static void saveOpp (Id oppId, Decimal netto, Decimal capfin, Decimal comm, Decimal durata, Decimal interessi, Decimal rata, Decimal tan, String finalita, Id istituto ) {
try {
 
    Opportunity queriedOpp = [SELECT Id, Prev_Netto_Erogato__c, Amount 
                              FROM Opportunity 
                              WHERE Id = :oppId
                              LIMIT 1];

    
    queriedOpp.Prev_Netto_Erogato__c = netto;
    queriedOpp.Prev_Capitale_Finanziato__c = capfin;
    queriedOpp.Prev_Commissioni__c = comm;
    queriedOpp.Prev_Durata__c = durata;
    queriedOpp.Prev_Interessi__c = interessi;
    queriedOpp.Prev_Rata__c = rata;
    queriedOpp.Tan__c = tan;
    queriedOpp.Prev_Finalita__c = finalita;
    queriedOpp.Prev_Istituto_Finanziario__c = istituto;
    

    
    update queriedOpp;
} catch(Exception e) {
    System.debug('An unexpected error has occurred: ' + e.getMessage());
}
}
}

and this is the test
@isTest 
private class calculatorControllerTEST { 
    private static testMethod void saveOppTEST () { 
		date d1 = date.newInstance(2016,01,12);
        Opportunity opp = new Opportunity(Name='aaa', CloseDate=d1, StageName='Qualificata');
        insert opp;

        calculatorController ctrl = new calculatorController ();
        calculatorController.saveOpp('0061j00000235a7', 333, 333, 333, 333, 333, 333, 3, 'CQS', '0011j000002GwXp');
    
    } 
}

​I can get only 33% of coverage.
Any Ideas?
Thank you in advance
Hi at all,
is it possible with validation rules or trigger to inhibit the conversion if it does not have the same name or surname?
I use personAccount and a matching rules with phone and mail but sometimes in personaccount I have a parent or friend with the same name and in the conversion I want to block salesperson convert lead in a existing Account that don't represent the person of the new lead.
Thank you in advance
Hi at all,
I'm trying to test this class 
//Send SMS (Routee)

public class sms {
 @AuraEnabled
   public static void sendSms(String destinatario, String testo){
     //Get Current User MobilePhone
     String mittente = [Select MobilePhone From User Where Id = :UserInfo.getUserId()][0].MobilePhone;
     mittente = mittente.deleteWhitespace();
     //Routee Authentication and Get Token  
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://auth.routee.net/oauth/token');
        req.setMethod('POST');
        req.setHeader('authorization', 'Basic xxxx');
        req.setHeader('content-type', 'application/x-www-form-urlencoded');
        req.setBody('grant_type=client_credentials');
                HttpResponse response = http.send(req);

        // Parse the JSON response
        if (response.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
            String json = response.getBody();
            
                    JSONParser parser = System.JSON.createParser(json);
                    while (parser.nextToken() != null) {
                        if(parser.getCurrentName() == 'access_token') {
                            parser.nextValue();
                            System.debug(parser.getText());
                            String access_token = parser.getText();
                        
                            // Send SMS
                            Http http1 = new Http();
                            HttpRequest req1 = new HttpRequest();
                            JSONGenerator body = System.JSON.createGenerator(true);
                                body.writeStartObject();      
                                body.writeStringField('from', mittente);
                                body.writeStringField('to', destinatario);
                                body.writeStringField('body',testo);
                                body.writeEndObject();    
                            String bodyS = body.getAsString();
                            req1.setEndpoint('https://connect.routee.net/sms');
                            req1.setMethod('POST');
                            req1.setHeader('authorization', 'Bearer '+ access_token);
                            req1.setHeader('content-type', 'application/json');
                            req1.setBody(bodyS);
                            HttpResponse response1 = http.send(req1);     
        					}

                    }
        }

   }
}


and this is test class:
@isTest
private class smsTest {

     
    @isTest static void testsendSms() {       
        // Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());

        
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        HttpResponse res = smsTest.sendSms('destinatario', 'testo');
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"example":"test"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
    }
}

Thanks in advance
Hi,
I can't test this class...
any idea?
//Send SMS (Routee)

public class sms {
 @AuraEnabled
   public static void sendSms(String destinatario, String testo){
     //Get Current User MobilePhone
     String mittente = [Select MobilePhone From User Where Id = :UserInfo.getUserId()][0].MobilePhone;
     mittente = mittente.deleteWhitespace();
     //Routee Authentication and Get Token  
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://auth.routee.net/oauth/token');
        req.setMethod('POST');
        req.setHeader('authorization', 'Basic xxxx');
        req.setHeader('content-type', 'application/x-www-form-urlencoded');
        req.setBody('grant_type=client_credentials');
                HttpResponse response = http.send(req);

        // Parse the JSON response
        if (response.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
            String json = response.getBody();
            
                    JSONParser parser = System.JSON.createParser(json);
                    while (parser.nextToken() != null) {
                        if(parser.getCurrentName() == 'access_token') {
                            parser.nextValue();
                            System.debug(parser.getText());
                            String access_token = parser.getText();
                        
                            // Send SMS
                            Http http1 = new Http();
                            HttpRequest req1 = new HttpRequest();
                            JSONGenerator body = System.JSON.createGenerator(true);
                                body.writeStartObject();      
                                body.writeStringField('from', mittente);
                                body.writeStringField('to', destinatario);
                                body.writeStringField('body',testo);
                                body.writeEndObject();    
                            String bodyS = body.getAsString();
                            req1.setEndpoint('https://connect.routee.net/sms');
                            req1.setMethod('POST');
                            req1.setHeader('authorization', 'Bearer '+ access_token);
                            req1.setHeader('content-type', 'application/json');
                            req1.setBody(bodyS);
                            HttpResponse response1 = http.send(req1);     
        					}

                    }
        }

   }
}

Thanks in advance
Hi,
I have this class
public class SmsClass {

    public static HttpResponse getInfoFromExternalService() {
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://auth.routee.net/oauth/token');
        req.setMethod('POST');
        req.setHeader('authorization', 'Basic xxxxxxx');
        req.setHeader('content-type', 'application/x-www-form-urlencoded');
        req.setBody('grant_type=client_credentials');

        Http h = new Http();
        HttpResponse res = h.send(req);
        return res;
		
 		if (res.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
                res.getStatusCode() + ' ' + res.getStatus());
        } else {
            System.debug(res.getBody());
            String json = res.getBody();
        }              

    }
}

and I receive unreachable statement error... 
Any Idea?
Thanks in advance
Hi,
when I invoke lightning:EditForm in a Component I have always to refresh and reedit record to save succesfully.
Thank in advance.
Here my component
<aura:component implements="force:appHostable,forceCommunity:availableForAllPageTypes" controller="updateLead" access="global">

<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
<aura:attribute name="lead" type="Lead" />
<aura:attribute name="stato" type="String" /> 
<aura:attribute name="isOpen" type="boolean" default="false"/>
<aura:attribute name="isOpenEdit" type="boolean" default="false"/>
<aura:attribute name="isOpenResp" type="boolean" default="false"/>
<aura:attribute name="title" type="String" />
<aura:attribute name="currentUser" type="User" />
    <force:recordData fields="Name, MobilePhone"
        recordId="{!$SObjectType.CurrentUser.Id}"
        targetFields="{!v.currentUser}"
        mode="VIEW"
    />    
    
    
        <lightning:card title="{!v.title}" iconName="standard:lead">
        <aura:set attribute="actions">
            
            <lightning:buttonGroup >
   
      
 <lightning:buttonMenu iconName="utility:close" alternativeText="Close" onselect="{!c.saveStatus}" title="Chiudi" >
    
     <lightning:menuItem label="Fake" value="Fake"/>
    <lightning:menuItem label="Non Contattabile" value="Not Contactable" />
     <lightning:menuItem label="Risponde Altra Persona" value="Risponde Altra Persona" />
	</lightning:buttonMenu> 
  
        <lightning:button iconName="utility:missed_call" onclick="{!c.openModel}" />
                <lightning:button iconName="action:check" onclick="{!c.respond}" />



    </lightning:buttonGroup>

        </aura:set>
        <!-- Grid Three Column -->   
<div class="slds-grid slds-gutters">
  <div class="slds-col ">
            <p class="slds-p-horizontal_small">
<dl class="slds-list_stacked">
    <dt class="slds-item_label slds-text-color_weak slds-truncate">Nome:</dt>
    <dd class="slds-item_detail slds-truncate">{!v.lead.FirstName}</dd>
    <dt class="slds-item_label slds-text-color_weak slds-truncate">Cognome:</dt>
    <dd class="slds-item_detail slds-truncate">{!v.lead.LastName}</dd>
    <dt class="slds-item_label slds-text-color_weak slds-truncate">Professione:</dt>
    <dd class="slds-item_detail slds-truncate">{!v.lead.Professione__c}</dd>
    <dt class="slds-item_label slds-text-color_weak slds-truncate">Campagna:</dt>
  	<dd class="slds-item_detail slds-truncate">{!v.lead.LeadSource} {!v.lead.CampaignID}</dd>
            </dl>
            </p>
  </div>
  <div class="slds-col">
            <p class="slds-p-horizontal_small">
<dl class="slds-list_stacked">
    <dt class="slds-item_label slds-text-color_weak slds-truncate">Cellulare:</dt>
  	<dd class="slds-item_detail slds-truncate">{!v.lead.MobilePhone}</dd>	
    <dt class="slds-item_label slds-text-color_weak slds-truncate">Telefono:</dt>
  	<dd class="slds-item_detail slds-truncate">{!v.lead.Phone}</dd>

    <dt class="slds-item_label slds-text-color_weak slds-truncate">Email:</dt>
  	<dd class="slds-item_detail slds-truncate">{!v.lead.Email}</dd>

            </dl>
            </p>
  </div>

            
            </div>
<div class="slds-clearfix slds-p-right_medium">
  <div class="slds-clearfix">
    <div class="slds-float_right">
      <lightning:buttonIcon iconName="utility:edit" variant="bare" onclick="{!c.openModelEdit}" /> 
    </div>
  </div>
</div>
 

    </lightning:card>
    
<!--###### MODAL BOX CALL ######--> 
  <!--Use aura:if tag to display Model Box, on the bese of conditions. [isOpen boolean attribute] -->   
    <aura:if isTrue="{!v.isOpen}">
      <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
        <div class="slds-modal__container">
          <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
          <div class="slds-modal__header">
            <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModel}">
            X
            <span class="slds-assistive-text">Chiudi</span>
            </button>
            <h2 id="header99" class="slds-text-heading--medium">Registra una Chiamata</h2>
          </div>
          <!--###### MODAL BOX BODY Part Start From Here ######-->
          <div class="slds-modal__content slds-p-around--medium">
            <p><c:LogACall recordId="{!v.lead.Id}" username="{!v.currentUser.Name}" usermobile="{!v.currentUser.MobilePhone}"/>
            </p>
          </div>

        </div>
      </div>
      <div class="slds-backdrop slds-backdrop--open"></div>
    </aura:if> 
<!--###### MODAL BOX Part END Here ######-->  
       
    
    
<!--###### MODAL BOX EDIT ######--> 
  <!--Use aura:if tag to display Model Box, on the bese of conditions. [isOpen boolean attribute] -->   
    <aura:if isTrue="{!v.isOpenEdit}">
      <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
        <div class="slds-modal__container">
          <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
          <div class="slds-modal__header">
            <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModelEdit}">
            X
            <span class="slds-assistive-text">Chiudi</span>
            </button>
            <h2 id="header99" class="slds-text-heading--medium">Modifica Lead</h2>
          </div>
          <!--###### MODAL BOX EDIT ######-->
          <div class="slds-modal__content slds-p-around--medium">
            <p>  <lightning:recordEditForm recordId="{!v.lead.Id}" objectApiName="Lead" >
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="MobilePhone" />
                <lightning:inputField fieldName="Phone" />
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Salva" />
    </lightning:recordEditForm>
            </p>
          </div>
       
        </div>
      </div>
      <div class="slds-backdrop slds-backdrop--open"></div>
      <!--###### MODAL BOX Part END Here ######-->  
 </aura:if>        
    
    

</aura:component>

and the controller
({
	doInit : function(component, event, helper) {
		var createddate =  component.get("v.lead.CreatedDate")
        createddate = ($A.localizationService.formatDate(createddate, "DD MMMM YYYY, kk:mm"));
        component.set("v.title", createddate);
	},
    
    saveStatus: function(component, event, helper) { 
        
        var status = event.detail.menuItem.get("v.value");
        component.set("v.lead.Status", status);
        var lead = component.get("v.lead");
        var action = component.get("c.saveLead");
        action.setParams({
    		leadupd : lead,

});
        $A.enqueueAction(action);
        $A.get('e.force:refreshView').fire();
        
    },
    
 navigate : function (component, event, helper) {
    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": component.get("v.lead.Id"),
      "slideDevName": "related"
    });
    navEvt.fire();
},
    
    
         //Modal popup
 openModel: function(component, event, helper) {
      // for Display Model,set the "isOpen" attribute to "true"

     component.set("v.isOpen", true);
   },
 
          //Modal popup
 openModelEdit: function(component, event, helper) {
      // for Display Model,set the "isOpen" attribute to "true"

     component.set("v.isOpenEdit", true);
   },
    
  respond: function(component, event, helper) {
     var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({
         "recordId": component.get("v.lead.Id")
   });
    editRecordEvent.fire();
  },
   closeModel: function(component, event, helper) {
      // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
      component.set("v.isOpen", false);
       $A.get('e.force:refreshView').fire();
   },
    
       closeModelEdit: function(component, event, helper) {
      // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
      component.set("v.isOpenEdit", false);
           $A.get('e.force:refreshView').fire();
       },


})

Hi,
public without sharing class ClosedTaskListController { @AuraEnabled public without sharing static List<Task> getTasks(ID whoId) { return [SELECT Id, Subject, Status, CreatedDate, Owner.Name, Description, Type FROM Task WHERE isClosed=True AND WhoId=:whoId ORDER BY createdDate DESC]; } }
I have this class. Users cannot see tasks of other users despite "without sharing" declaration.
Any idea?
Thansk in advance
Hi,
I'm tryng to use $CurrentPage.parameters.parametername in Customer community in a site.com builder page but I can only accesso to User / Site parameter. Any idea?
Hi,
I'm trying to get the ip of the visitor in a site.com page. Is there a way? I try with variabiles {!Request but I can only have browser and version from user agent.

Thanks
Hi,
I can't test this class...
public class smscontroller {
    //Send SMS (Routee)
    @AuraEnabled
    public static void sendsms(String WhoId, String WhatId, String testo, String destinatario){    
        //Get Current User MobilePhone
        String mittente = [Select MobilePhone From User Where Id = :UserInfo.getUserId()][0].MobilePhone;
        mittente = mittente.deleteWhitespace();
		//Routee Authentication and Get Token
        Http http = new Http();
		HttpRequest request = new HttpRequest();
        request.setEndpoint('https://auth.routee.net/oauth/token');
        request.setMethod('POST');
        request.setHeader('authorization', 'Basic xxxxxxxxxxxxxxxxx');
        request.setHeader('content-type', 'application/x-www-form-urlencoded');
        request.setBody('grant_type=client_credentials');
		HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
            String json = response.getBody();
			JSONParser parser = System.JSON.createParser(json);
                    while (parser.nextToken() != null) {
                        if(parser.getCurrentName() == 'access_token') {
                            parser.nextValue();
                            System.debug(parser.getText());
                            String access_token = parser.getText();
                            // Send SMS
                        	Http http1 = new Http();
                            HttpRequest request1 = new HttpRequest();
                            JSONGenerator body = System.JSON.createGenerator(true);
                            	body.writeStartObject();      
                                body.writeStringField('from', mittente);
                                body.writeStringField('to', destinatario);
                            	body.writeStringField('body',testo);
                                body.writeEndObject();    
                            String bodyS = body.getAsString();
                            request1.setEndpoint('https://connect.routee.net/sms');
                            request1.setMethod('POST');
                            request1.setHeader('authorization', 'Bearer '+ access_token);
                            request1.setHeader('content-type', 'application/json');
                            request1.setBody(bodyS);
                            HttpResponse response1 = http.send(request1);
                        	String json1 = response1.getBody();

                            //Insert Log Task
                            Task Task = new Task();
                            task.WhoId = Whoid;
                            task.WhatId = WhatId;
                            task.ActivityDate = system.today();
                            task.Subject = json1 ;
                            task.Description = json1;
                            insert task; 
                        }
                    }
        		}
    	}
}

Any ideas?
Thankyou
Hi,
I try with this solution,
https://developer.salesforce.com/forums/?id=9060G0000005Pc1QAE
but It returns the ip ogf salesforce server. I want to get ip of client guest user of a ligghtning community.
Is there a solution?
Thankyou in advance
Hi, is there a way to get the ip address of the connected guest user?
I try the below code but it works for the logged user but returns null for the guest users:
@AuraEnabled   
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

I also try with a callout but it returns ip of salesforce server
 
Hi,
I'm trying to test a class wher I get current User Ip
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

return ReturnValue;
} // GetUserIPAddress



Test class:

 public static testmethod void Test1()
 {System.runAs(new User(Id = UserInfo.getUserId())){
     
     String ip = siteLeadForm.GetUserIPAddress();}
       
        

    }

In sandbox it is ok, but in production I receive this error:
System.UnexpectedException: Current session unavailable 
Stack Trace: Class.Auth.SessionManagement.getCurrentSession: line 5, column 1 Class.siteLeadForm.GetUserIPAddress: line 18, column 1 Class.siteLeadFormTEST.Test1: line 17, column 1


Any Ideas?
thankyou in advance
Hi,
i'm trying to get ip address of the client in a lightning component in a community but i receive Server error.
@AuraEnabled    
public static String GetUserIPAddress() {
string ReturnValue = '';
ReturnValue = ApexPages.currentPage().getHeaders().get('True-Client-IP');
if (ReturnValue == '') {
ReturnValue = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
} // get IP address when no caching (sandbox, dev, secure urls)
system.debug('USER IP ADDRESS: ' + ReturnValue);
return ReturnValue;
} // GetUserIPAddress

Any Ideas?
Hi,
I can't test this class...
any idea?
//Send SMS (Routee)

public class sms {
 @AuraEnabled
   public static void sendSms(String destinatario, String testo){
     //Get Current User MobilePhone
     String mittente = [Select MobilePhone From User Where Id = :UserInfo.getUserId()][0].MobilePhone;
     mittente = mittente.deleteWhitespace();
     //Routee Authentication and Get Token  
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://auth.routee.net/oauth/token');
        req.setMethod('POST');
        req.setHeader('authorization', 'Basic xxxx');
        req.setHeader('content-type', 'application/x-www-form-urlencoded');
        req.setBody('grant_type=client_credentials');
                HttpResponse response = http.send(req);

        // Parse the JSON response
        if (response.getStatusCode() != 200) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
            String json = response.getBody();
            
                    JSONParser parser = System.JSON.createParser(json);
                    while (parser.nextToken() != null) {
                        if(parser.getCurrentName() == 'access_token') {
                            parser.nextValue();
                            System.debug(parser.getText());
                            String access_token = parser.getText();
                        
                            // Send SMS
                            Http http1 = new Http();
                            HttpRequest req1 = new HttpRequest();
                            JSONGenerator body = System.JSON.createGenerator(true);
                                body.writeStartObject();      
                                body.writeStringField('from', mittente);
                                body.writeStringField('to', destinatario);
                                body.writeStringField('body',testo);
                                body.writeEndObject();    
                            String bodyS = body.getAsString();
                            req1.setEndpoint('https://connect.routee.net/sms');
                            req1.setMethod('POST');
                            req1.setHeader('authorization', 'Bearer '+ access_token);
                            req1.setHeader('content-type', 'application/json');
                            req1.setBody(bodyS);
                            HttpResponse response1 = http.send(req1);     
        					}

                    }
        }

   }
}

Thanks in advance
Hi,
public without sharing class ClosedTaskListController { @AuraEnabled public without sharing static List<Task> getTasks(ID whoId) { return [SELECT Id, Subject, Status, CreatedDate, Owner.Name, Description, Type FROM Task WHERE isClosed=True AND WhoId=:whoId ORDER BY createdDate DESC]; } }
I have this class. Users cannot see tasks of other users despite "without sharing" declaration.
Any idea?
Thansk in advance
Hi 

I have scnerio where I need to capture IP address of current User in Lightning Community, is any way standard way  where I can capture IP address inside Lightning Components.
I have seen third party tools like - https://www.ipify.org/ to get Ip address 
Any recommendations are appreciated 

Thanks