• Ell
  • NEWBIE
  • 70 Points
  • Member since 2018
  • CTO
  • Appitek

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

Hello everybody

I am currently ttying to insert records into Salesforce using apex; the records i need are saved as .csv files inside Salesforce in the ContentDocument object. I can get the name of the object from the name of the file, that will be for example: backup_Account_mm/dd/yyy. So i can only get the name of the obj as a string.

How can i build the logic for inserting records (.csv file) based on the object, considering that the objects can change, and i'd rather not use hard coding.

Thanks in advance 

Hello,

We've configured Salesforce LiveChat & Chatbot on our salesforce sandbox environment and it's working well. The only thing we noticed is that to hook it up to our public site we had to keep the org ID itself exposed in the source of the page itself, meaning when it goes live, it would be publically available to any internet user which is undesirable and poses a security risk. Is there anything we can do to mask / hide the value?

Kind Regards,
David

Hey guys,

I was wondering if anyone has tried getting a timestamp before and after a HTTPRequest? I want to create a record to log each transaction to a third-party system with a 'Start' and 'End' time. I could add the 'End' time into the response of the request, but wondered if there was a way to get it in Apex, as using DateTime.now() seems to give the same value before + after.

I have a @Future method calling some code that basically follows a format of:

Create an empty record with the start time as DateTime.now();
Run a HttpRequest
Set the record's end time as DateTime.now(), along with some data from the response
Insert the record

i.e.
// create log
Log__c log = new Log__c();
log.Start_Time__c = DateTime.now();

// send request
HttpRequest req = new HttpRequest();
req.setEndpoint('URL');
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);

// update log
log.Response__c = res.getBody();
log.Status__c = res.getStatusCode();
log.End_Time__c = DateTime.now();
insert log;
But both the DateTime.now() stamps are exactly the same. I thought that as the request has been processed (due to values being on the record from the response) that the second DateTime.now() would have the time after request, but is that not how it works in this context?

Cheers
  • October 11, 2018
  • Like
  • 0
Hi All,

I am appending colon within <aura:iteration> between each values, but the issue is the colon is getting appended even after the last value. i need it till the last value and not after the last value.
<aura:iteration items="{!item.category}" var="category">
                                      <c:Link class="full-width" recordId="{!category.Category_Id__c}" objectApiName="Category__c" label="{!category.Name}"/> 
                                      <aura:if isTrue="{! !empty(item.category)}">
  										  :
 									  </aura:if>
                                      
                                      </aura:iteration>

 
I am integrating with a managed package that returns an Object, not an Sobject, but a plain Object in Apex. Using System.Debug the following is shown:

    {nbrRows=1, rowIds=()}

I want to parse this returned data so that I can extract specific values from the object such as "nbrRows". I have already tried "JSON.deserializeUntyped" but due to the format not being typical JSON this did not work. I also tried "getPopulatedFieldsAsMap" but learn that this only works with SObjects, not an object.

Is there a simple way to parse the data above? Thanks in advance!
{
    "statusCode": 400,
    "status": "Error",
    "recordReferences": [],
    "errors": [
        {
            "recordId": "Class.System.JSON.deserialize: line 15, column 1\nClass.GlobalWS.processTable: line 33, column 1",
            "errorMessage": "Illegal value for primitive"
        }
    ]
}
please help me
 
third party need to pass a list of values in the request body of POST method but I get 400: Bad Request error.
Third party JSON using like below
{"entityName":"Invoice","records":[{
"company_id":"YKY7EP1K1",
//below product items will have multiple values which would be in string.
"product_items":["apple","orange"],
"workflow_state":null
}]
}
so how could I develope product_items to assign this array string values to my Invoice object field. Webservice already got developed and its running fine but this new field got created recently and third party want to send in array format so how could I implement it.
Thanks in advance 
I wanted to pass Refresh tokan via HEADER using postman (I know how to get refresh token) but I don't know how to pass it

What key I have to use? And how I pass the value? I tried to pass it at Authorization key and Value "Authorization Bearer <<refresh_token>>" but it didn't works

User-added image
I am using Visualforce page and i want table of content(index) with page number.

i am using the below code but i am not getting page number.
or is there any other way to do the same?

in vf page for index:
<nav>
<ol>
<li class="bodymatter "><a href="#intr_01">Introduction</a></li>
<li class="bodymatter"><a href="#chap_01">Chapter One</a></li>
</ol> </nav>

vf page with content:
<h1 id="intr_01"> Introduction</h1>
<p>some logic</p>
<h1 id="chap_01"> Chapter One</h1>
<p>some logic</p>

CSS:
.bodymatter a::after { content: leader('.') target-counter(attr(href url), page, decimal) }

Result expected:
Introduction.........1
Chapter One...........2
Hi,
I am trying to update a metadata field and get an error as seen below.
Will appreciate any help!
Thx
Yoram

Below are 2 REST queries that I am performing.
1. The first on gets all the complianceGroup fields form fieldDefinition for a certain object.
From the query I get the complianceGroup Id and url.
2. The second one tires to patch a new value to the url and id received in the first query.

First select query:
https://um6.salesforce.com/services/data/v49.0/tooling/query/?q=Select+Id,+complianceGroup+From+FieldDefinition+WHERE+EntityDefinitionId+in('Account')

The result is:
Url: /services/data/v49.0/tooling/sobjects/FieldDefinition/Account.Fax
Id: 000000000000000AAA

Second select query:
Header: PATCH https://um6.salesforce.com/services/data/v49.0/tooling/sobjects/FieldDefinition/Account.Fax/000000000000000AAA HTTP/1.1

The result for this query is the following error:
[ {
  "errorCode" : "NOT_FOUND",
  "message" : "The requested resource does not exist"
} ]

This is the java code for the seocnd select query:
private void setComplianceGroupValue(String complianceUrl, String id, ArrayList<String> categories) throws ParseException, IOException, ResponseNotOKException {

        for (Iterator iterator = categories.iterator(); iterator.hasNext();) {
            String currentCagtegory = (String) iterator.next();

            //Set up the HTTP objects needed to make the request.
            HttpClient httpClient = HttpClientBuilder.create().build();
            HttpPatch patch = new HttpPatch(complianceUrl + "/" + id);
            Header oauthHeader = new BasicHeader("Authorization", "OAuth " + loginAccessToken);
            Header prettyPrintHeader = new BasicHeader("X-PrettyPrint", "1");    
            //Header xss = new BasicHeader(("X-XSS-Protection: 1; mode=block"), uri);
            patch.addHeader(oauthHeader);
            patch.addHeader(prettyPrintHeader);
            //patch.addHeader(xss);
            //patch.setHeader("Content-type", "application/json");

            JSONObject jasonCategory = new JSONObject();
            jasonCategory.put("id", id);
            jasonCategory.put("ComplianceGroup", currentCagtegory);
            
            
            StringEntity body = new StringEntity(jasonCategory.toString());
            
            body.setContentType ("application/json");
            //body.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
            patch.setEntity(body);
            // Make the request.
            HttpResponse response = httpClient.execute(patch);
            String getResult = EntityUtils.toString(response.getEntity());
            // if respone is not 200 (ok) than an exception is thrown
            proccessHttpResponse(response, complianceUrl+ "/" + id);
                
            LoggerSingelton.getInstance().getLogger().info("postAttributes result: {}. {}", getResult ,SalesforceRestService.class.getSimpleName());
        }
    }
 
hello there
we are subscription based

how does your tream track renewals? we are looking to add a field to the account object - would this be date based?

we would then want to automate a task when the renewal is reached - so would a date based value be best?

thank you
Hi everyone, 

I was wondering if someone can help me?

I'm actually having an issue when trying to "save" the record (pressing "Cancel" on the record is fine) after pressing the custom URL button. 

Here's a video example:
https://www.screencast.com/t/hrOkuHx4

Let me give you some background:

As we're transitioning to Lightning, the business is requiring Lead information to be populated to activities (which can't be done using Actions). I've created a URL hack for "New Task" which displays near the buttons on the Lead lightning page. Pressing the "New Task" button (and cancelling) is working fine, but when I try to "save" the Task record, it re-directs me to the Task page, despite having &retURL at the end of my hyperlink. 

I've tried every possible solution I can think of, but this issue still persists. Can somebody please help me if they know how to return to the record the button was pressed on? (in my case, Lead)

My URL example:
/lightning/o/Task/new?defaultFieldValues=
{!IF(ISBLANK(Lead.AccountId__c),'','WhatId='&Lead.AccountId__c)},
{!IF(ISBLANK(Lead.Primary_ContactId__c),'WhoId='&Lead.Id,'WhoId='&Lead.Primary_ContactId__c)},
Lead_Lookup__c={!Lead.Id}
&retURL=%2F{!Lead.Id},
backgroundContext=%2Flightning%2Fr%2FLead%2F{!Lead.Id}%2Fview

Regards,
VJ

Hello everybody

I am currently ttying to insert records into Salesforce using apex; the records i need are saved as .csv files inside Salesforce in the ContentDocument object. I can get the name of the object from the name of the file, that will be for example: backup_Account_mm/dd/yyy. So i can only get the name of the obj as a string.

How can i build the logic for inserting records (.csv file) based on the object, considering that the objects can change, and i'd rather not use hard coding.

Thanks in advance 

Hello,

We've configured Salesforce LiveChat & Chatbot on our salesforce sandbox environment and it's working well. The only thing we noticed is that to hook it up to our public site we had to keep the org ID itself exposed in the source of the page itself, meaning when it goes live, it would be publically available to any internet user which is undesirable and poses a security risk. Is there anything we can do to mask / hide the value?

Kind Regards,
David

Hey guys,

I was wondering if anyone has tried getting a timestamp before and after a HTTPRequest? I want to create a record to log each transaction to a third-party system with a 'Start' and 'End' time. I could add the 'End' time into the response of the request, but wondered if there was a way to get it in Apex, as using DateTime.now() seems to give the same value before + after.

I have a @Future method calling some code that basically follows a format of:

Create an empty record with the start time as DateTime.now();
Run a HttpRequest
Set the record's end time as DateTime.now(), along with some data from the response
Insert the record

i.e.
// create log
Log__c log = new Log__c();
log.Start_Time__c = DateTime.now();

// send request
HttpRequest req = new HttpRequest();
req.setEndpoint('URL');
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);

// update log
log.Response__c = res.getBody();
log.Status__c = res.getStatusCode();
log.End_Time__c = DateTime.now();
insert log;
But both the DateTime.now() stamps are exactly the same. I thought that as the request has been processed (due to values being on the record from the response) that the second DateTime.now() would have the time after request, but is that not how it works in this context?

Cheers
  • October 11, 2018
  • Like
  • 0

Is there a way to get the instance url for a specific sandbox without being logged into that org? 

I am attempting to assemble a list of Sandbox orgs along with their corresponding instance url's.  The idea being that logging in via test.salesforce.com leaves it up to the user which org they log into.  But if you direct them directly to the instance url, they will connect to the correct org.  As well as catching when an org is refreshed, and directing them to the correct page.  This is for an admin-type application where I have full access to the production org for any queries.

Via the tooling api, I have retrieved a list of SandboxInfo records that give me the active sandboxes.  Using the sandbox names found there, I can get the Org Id from SandboxProcess.  But from there, I'm stuck.  If you go via the UI, Salesforce gives you the option to login to a sandbox from the Setup->Sandboxes page, and it directs you to the correct instance url, so the information is obviously present somewhere.  

Put another way, I have an org id, is there a way via the production org and only using apis to figure out the instance url of the sandbox?

Thanks,
-Sean