+ Start a Discussion
Roman RauerRoman Rauer 
Hi there :)

i'm currently working on an native Android app for my company and ran into some problems with Salesforce lately.

I hope i can find some help here.

What i want to achieve:
The company has a lot of Accounts in Salesforce with 3 important fields for the app: Name, Business (Workshop or Parts Dealer) and location(latitude, longitude)
I would like to show those Accounts(Workshops/Parts Dealers) as markers on a google map in my Android app based on a radius around the user's current location. So it would be more than sufficient to get the data as JSON or XML(i read about sObjects, which would be nice too)

The app will be freely available on Google Play Store and every user should be able to see all the Workshops/Parts dealers around the world.

The problem i'm facing is that i can't find a way to fetch the data inside my app without authenticating every user with a Salesforce-Login. 
Which API is the best to use in this case?

It would be so awsome if anybody could help me with this problem.

What i tried so far: 
- SalesforceMobileSDK: If i extend SalesForceApplication i always end up with the Salesforce-Login Screen.
It seems that every client has to be authenticated for API-calls to work. I tried using the method "peekUnauthenticatedRestClient", but this method only works on full path URL's(e.g. "https://api.spotify.com/v1/search?q=James%20Brown&type=artist"), which isn't really practically for my Use-case.

- I feel like i read nearly all docs about salesforce api, but can't quite get my head around how to solve this problem, although it seems like to be a pretty common use-case.  

- would a salesforce-apex method which would select all records inside a set radius around the user's location be accessable without authentication?

Thanks for your help in advance!

Roman
Best Answer chosen by Roman Rauer
Santosh Bompally 8Santosh Bompally 8
Follow this -> 
1) Write a Restservice to expose your data. 
@RestResource(urlMapping='/Account')
global with sharing class MyRestResource {

 
    @HttpGet
    global static List<Account> doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
       List< Account>  result = [SELECT Id, Name, Business,Location FROM Account ];
        return result;
    }
  
}

2)  Create a Community and provide access to apex class and account object to the Guest user profile. 
    Samplecommunity url -> https://somedomain.cs16.force.com/communityname

3) Go to workbench and test your API using rest explorer 
    relative url ->  /services/apexrest/Account
4) Your public url will now be   https://somedomain.cs16.force.com/communityname/services/apexrest/Account 

Mark as Best Answer if it helps. 

Thanks, 
Santosh 

 
RiyajRiyaj 

How do I solve the error

REQUEST_LIMIT_EXCEEDED: TotalRequests Limit exceeded.

 

Riyaj

Best Answer chosen by Admin (Salesforce Developers) 
TheIntegratorTheIntegrator

You can check the API Requests from Setup->Administration Setup->Company Profile->Company Information

 

API Requests, Last 24 Hours , is the number there is exceeding MAX number in paranthesis, you get this error.

 

You either have to wait till that number goes down or purchase more licenses to raise the MAX limit if you expect the usage to always be higher that what your current MAX is.

 

Adam TossellAdam Tossell 
Hi Guys. 
I have just begun the SuperBadge: Lightning Experience Specialist. I am unable to rename standard objects. Any thoughts? 
Cheers. 
Mark
Best Answer chosen by Adam Tossell
Parker EdelmannParker Edelmann
Hello again Mr. Tossell,

In order to rename the label of Standard Objects, their tabs, and/or their fields, search "rename" in the quick find box. Rename Tabs & Labels should come up, you can't miss it. I've attached two screenshots to illustrate this. They show the Lead object being renamed, but it's the same for other Standard and Custom Objects.

User-added image

User-added image

I just finished the LEX Superbadge myself, so if you have any more questions, feel free to post to my Success Community feed.

Thanks,
Parker Edelmann
rima khanrima khan 
Hi!
I registered with trailhead.
I’m an SDR looking to expand my Salesforce skill set. Let’s pretend I have none. Particularly looking for the basics around reporting, and any other trails that may be beneficial to spend some time with.
My goal is to have a competent understanding of SF to build my sales as I enter a closing role and the relevant tools in SF that will help me gain an advantage.
Thanks in advance!
Best Answer chosen by rima khan
manasa udupimanasa udupi
Hi Rima,

Below are few trailhead links, hope it helps:)

https://trailhead.salesforce.com/en/content/learn/modules/sales_admin_sales_reports_for_lex
https://trailhead.salesforce.com/en/content/learn/modules/sales-activity-analysis
Gargi ManjeeGargi Manjee 
Dear All,

I have created global action with VF and Controller to get users current location.
It is working fine on web (laptop) but the same code is not working in android.

Kindly help.
Best Answer chosen by Gargi Manjee
Gargi ManjeeGargi Manjee
Thank you everyone for all the answers.
The issue was 'highaccuracy' option was not selected on the device and whereas I was passing highaccuracy = true while calling navigator.geolocation.getCurrentPosition function.
AntonyWarcAntonyWarc 

Hi,

 

We have a 3rd party webserivce that send leads from our site to SF with Lead Owner already assigned based on some coded rules. We now want to add a level of lead assignment above what this can handle, so I wrote a lead assignment rule and have activated it.

 

The rules seem to be completley ignored as leads are coming in, but work if a lead is edited and saved ticking the "use active assignmnet rules" checkbox. (i.e the lead assignment crieria works, but its not being triggered)

 

So I thought a trigger to re-run lead assignment directly after a lead has been created would be the only solution, issue is I have no coding experience (aside from one easy update trigger some guys on here helped with!)

 

Can anyone help? Or if another solution exists that woudl be great too!

 

Antony

Best Answer chosen by Admin (Salesforce Developers) 
CheyneCheyne

You could use the AssignmentRuleHeader in an Apex trigger, as in this post:

 

http://salesforce.stackexchange.com/questions/13651/lead-assignment-rule-in-a-trigger

 

I assume you'll only want to reassign leads that came from your website, so you'll need a way to check that in your trigger. Assuming these leads have a source of "website", and drawing off of the example above, you could write something like

 

trigger LeadTrigger on Lead (after insert) {
    List<Lead> ls = new List<Lead>();

    for (Lead l : Trigger.new) {
        if (l.LeadSource = 'Website') {
            ls.add(new Lead(id = l.id));
        }
    }

    Database.DMLOptions dmo = new Database.DMLOptions();
    dmo.assignmentRuleHeader.useDefaultRule = true;
    Database.update(ls, dmo);
}

 If you're able to modify the code that is sending the leads from your site to Salesforce, you could set the AssignmentRuleHeader from that end as well.

Raj Pandey 29Raj Pandey 29 
trigger onlyoneaccountopportunitycreate on Opportunity (before insert) {

    Set<id> accId = new Set<id>(); // Always try to use set
    for(opportunity opp : trigger.new)
    {
        if(opp.AccountId != null)
        {
            accId.add(opp.AccountId);    
        }
        }
    

    Map<Id,Account> mapAccount = new Map<Id,Account> ( [select id,(select id from opportunities) from account where id IN : accId ]) ;
    for(opportunity opp:trigger.new)
    {    
        
        if( opp.AccountId != null && mapAccount.containsKey(opp.AccountId) )
        {
            Account acc = mapAccount.get(opp.AccountId);
            if(acc.opportunities.size() > 0 )
            {
                opp.addError('you can not add more then once opportunity for this account'); 
            }
        }
    }

}

Please see the above code & help me to write a trigger that allow only one opportunity associated with an account in a day.
Best Answer chosen by Raj Pandey 29
Abhishek BansalAbhishek Bansal
Please close this question by marking the answer as Best Answer so that it will be helpful to others 
Naren9Naren9 
Hi All,
In Salesforce Lightning, do we have any option to remove/disable the Drilldown/View report hyper link on Dashboard?.

Thanks,
Naren
Best Answer chosen by Naren9
NagendraNagendra (Salesforce Developers) 
Hi Naren,

Sorry for this issue you are facing.

Unfortunately, this is not possible as of now. There is an idea which is active on the success community for which you can upvote so that it can be available in the mere future.

You can find the idea at the below link. Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
TemesgennnTemesgennn 

Hi all,

Is it possible to display a spinner while a visualforce component is loading in our Org? We created a visualforce page and used it as a component to display a table for our users. I have tried some solutions but no success so far, my code and solution could be totally wrong i am new to this.

Thank you very much for your help, this is my code:
 

<apex:page standardController="Class__c" extensions="ClassAttendanceTableController" lightningStylesheets="true">

    <head>
        <apex:slds />
    </head>
    <apex:form>
        <style>
                .spinnerBg{
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    background-color: #000;
                    opacity: 0.2;
                    z-index: 999999;
                }
                .spinner{
                    width: 100%;
                    height: 100%;
                    position: absolute;
                    background-image: url("/img/loading32.gif");
                    background-size: 16px;
                    background-repeat: no-repeat;
                    background-attachment: fixed;
                    background-position: center;
                    z-index: 9999999;
                    opacity: 1;
                }
   </style>
   
    <apex:actionStatus id="spinnerStatus">    
                    <apex:facet name="start">
                     <div class="spinnerBg" />
                    <div class="spinner" />
                </apex:facet>
    </apex:actionStatus>
   
     <apex:commandButton action="{!save}" value="Save" status="spinnerStatus" reRender="theForm"/>
        <table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_col-bordered slds-scrollable" >
            <thead>
                <tr class="slds-line-height_reset">
                    <th scope="col">
                        <div class="slds-truncate" title="Student Name">Student</div>
                    </th>
                    <apex:repeat value="{!attendanceDates}" var="date">
                        <th scope="col">
                            <div class="slds-truncate">
                                <apex:outputText value="{0, date, MMMM d',' yyyy}">
                                    <apex:param value="{!date}" />
                                </apex:outputText>
                            </div>
                        </th>
                    </apex:repeat>
                </tr>
            </thead>
            
            <tbody>
                <apex:repeat value="{!attendanceNames}" var="name">
                    <tr>
                        <td data-label="Student Name" scope="row" class="slds-truncate">
                            <apex:outputText value="{!name}" />
                            <apex:repeat value="{!attendanceRecords}" var="records">
                                <apex:outputPanel rendered="{!name == records.Student__r.name}">
                                    <td data-label="Present">
                                        <apex:inputField value="{!records.Present__c}" id="present" />
                                    </td>
                                </apex:outputPanel>
                            </apex:repeat>
                        </td>
                    </tr>
                </apex:repeat>
                
            </tbody>
            
        </table>
    </apex:form>
    
</apex:page>
Best Answer chosen by Temesgennn
ANUTEJANUTEJ (Salesforce Developers) 
Hi Temesgenn,

>> https://salesforce.stackexchange.com/questions/191203/visualforce-with-slds-spinner-embedded-in-a-page-layout#:~:text=If%20you%20want%20to%20use,live%20in%20an%20apex%3AactionStatus.

>> https://salesforce.stackexchange.com/questions/65580/popup-spinner-style-apexactionstatus

I was able to find the above implementation that has the similar use case of showing a spinner on the visualforce page when the data is loading, can you try checking this once?

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
Salesforce Developer 60Salesforce Developer 60 
Hello ,
         I create a webservice for consuming rest api from .net . I am facing issue in test class for this . It's gives error callout not allowed from test method. How to write test class for below controller.
 
public with sharing class WebserviceCall {

    public WebserviceCall(ApexPages.StandardController controller) {

    }

    public String message {get; set;}
    
    public PageReference getaccesstoken() { 
      string jsonstring ='userName=test@gmail.com&Password=123&grant_type=password';
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
       // req.setClientCertificateName('Client Certificate');
       
        req.setEndpoint('http://google.com');
        req.setMethod('POST');
       // req.setHeader('SOAPAction', 'Soap Action');
        //req.setHeader('Authorization','Auth Token');
      
       req.setBody(jsonstring);
 
           try {
            res = http.send(req);
            message = res.getBody();
    TokenInformation token = new TokenInformation();
    token =(TokenInformation)System.JSON.deserialize(message, TokenInformation.class);
  // JSONParser parser = JSON.createParser(res.getBody());
            System.debug(token.access_token);
                 //HttpServletResponse httpResponse = (HttpServletResponse)response;
              string s = token.access_token;
            string a1 = s.substring(0,255);
            string a2 = s.substring(255,510);
            string a3 =s.substring (510,s.length());
            //Here SessionData__c is custom setting used for store access_token
       SessionData__c objToken = new SessionData__c();
       objToken.Name ='token2';
       objToken.Id ='a0G28000000ENAI';
    objToken.Access_Token1__c =a1;objToken.Access_Token2__c =a2;
               objToken.Access_Token3__c =a3;

upsert objToken;
               
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
             message = res.toString() + res.getBody();
            System.debug(res.toString());
        }
        return null;
        
}       
    
    
    
    
}

Best Answer chosen by Salesforce Developer 60
Shrikant BagalShrikant Bagal
Please try following 

/* MockResponse class implementing the HttpCalloutMock interface */
-----------------------------------------------------------------------------------------------------------------------------------------------------
@isTest
global class MockHttpResponseGenerator implements HttpCalloutMock {
   // Implement this interface method
    global HTTPResponse respond(HTTPRequest req) {
        // Optionally, only send a mock response for a specific endpoint
        // and method.
        System.assertEquals('http://google.com', req.getEndpoint());
        System.assertEquals('POST', req.getMethod());
  
       // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('{"access_token":"8UT28QKGORMivFqne-6PMRLdTYk3AS0mcxdVwRJEwYsTjwZjqGopk1TRzGX7vHSZpFNFL3HOmX3RKZrQkBap3b16j-XVkwArdDbhusArOBGzYsD1cpA8B87N_RedJrd9btvq2i22cAjPvyJLSVMc297U0V9YZ9rJ3tM429G8mglnsUNUVJJi_nnTJAN6-H038B4Y1aQeRQZVdU72Nr942eYZ3fXv1HXfxwYUZgWyYO5juVaVnoq_ZJHcrFGXfNp5LVrNlnEibHhJ2RGeD-MYKhyVjfkTrATGQhYY--OVCOemUyWKTlwgwBFjgzfpQfOq79raEglOTgEF3Qx78RY2-nBNvgOTRMET4B2fT17Q8EN4UCQLxGZTGq1ACN5j2B3YKT7isjzwAgysloYGJsL4j4D8dCGKgWBO0rTXwx7MfkNsX5TjAYRNCip5vTSRXeSBqhjM_TtwbKCA0HexikSz-XryZT7pKGYhjfRCXtWudd7OUjFYoDRfKTiAhjNk5yJj","token_type":"bearer","expires_in":86400,"userName":"test@gmail.com",".issued":"Thu, 25 Jun 2015 12:56:23 GMT",".expires":"Fri, 26 Jun 2015 12:56:23 GMT"}');
        res.setStatusCode(200);
        return res;
    }
}



----------------------------------------------------------------------------------------------------------------------------------------------------------------
/* Test Class getting fake response  from the class MockHttpResponseGenerator that implements HttpCalloutMock */
@isTest
private class CalloutClassTest {
     @isTest static void testCallout() {
       // 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.
        PageReference pageRef = new WebserviceCall().getaccesstoken();
    }
}



Please mark as best answer so it will help to other who will serve same problem.
​Thanks!