• Arghyadeep Sur
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
public class UpdatePostCallout11 {

@InvocableMethod(label='Update Post details based on Post ID')
public static void updatePost(List<Id> postLIst){
if (postLIst != null && postLIst.size() > 0){
getCalloutResponse(postLIst);
}
}
@future(callout = true)
public static void getCalloutResponse(List<Id> postLIst){
postWrapper postWrapperObj;
List<postInformation> postInfoList = new List<postInformation>();
Map<Integer, String> postTitleMap = new Map<Integer, String>();
// Perform Rest Callout
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://jsonplaceholder.typicode.com/posts');
request.setMethod('GET');
HttpResponse response = http.send(request);
String responseBody = null;
if (response.getStatusCode() == 200){
responseBody = response.getBody();
System.debug('Response Received: '+ responseBody);
}
// If the REST API Response is not null, deserialize the Response and store id, postTitle in map
if (String.isNotBlank(responseBody)){
postWrapperObj = (postWrapper)System.JSON.deserialize(responseBody, postWrapper.class);
if (postWrapperObj != null) {
postInfoList = postWrapperObj.data;
}
if (postInfoList.size() > 0){
for(postInformation obj : postInfoList){
postTitleMap.put(obj.id, obj.postTitle);

}
}
}

List<Post__c> PstListToUpdate = new List<Post__c>();
List<Post__c> PostRecords = [Select Id, Id__c, Title__c from Post__c where Id IN: (postLIst)];
if (PostRecords != null && PostRecords.size() > 0){
for(Post__c PstObj : PostRecords){
if (postTitleMap != null && postTitleMap.containsKey(Integer.valueOf(PstObj.Id__c))){
PstObj.Title__c = postTitleMap.get(Integer.valueOf(PstObj.Id__c));
PstListToUpdate.add(PstObj);
}
}
}
if (PstListToUpdate.size() > 0)
update PstListToUpdate;
}
public class postWrapper{
public List<postInformation> data;
}
public class postInformation{
public Integer id;
public String postTitle;
}
}
Hello Everyone,

I am using an lwc component on which users will upload a file and they can also preview that. For a preview, I am using navigationMixin and navigate the record to standard_namedPage which working fine for internal use but the same method is not working in the community. I am not able to preview the file using that. Today I did some research and get to know standard_namedPage not supported community and for that, I need to use standard_webPage which redirects me to the new tab and I can see my file there but the issue is on that new tab I can see my file as a thumbnail, not the actual file. Can someone guide me on how can I preview files in the community as the original file?
Below is the code that I am using for both internal and external.
 
Internal:
this[NavigationMixin.Navigate]({
type: 'standard__namedPage',
attributes: {
pageName: 'filePreview'
},
state : {
// assigning ContentDocumentId to show the preview of file
selectedRecordId:event.currentTarget.dataset.id
}
})

External:
//Getting content version id to assign the url.
contentVersionId = response;
var baseURL = 'https://'+location.host+'/';
var previewURL = baseURL + 'sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId='+contentVersionId;
this[NavigationMixin.Navigate]({
type: 'standard__webPage',
attributes: {
url: previewURL
}
}, false );

Thanks,
Arpit Jain
My auto launched Flow won't work because it is sending an email and the From is the Automated User email, which is not valid, I am told. 
Where and how can I access this Automated User, and edit the email of this user?
public class UpdatePostCallout11 {

@InvocableMethod(label='Update Post details based on Post ID')
public static void updatePost(List<Id> postLIst){
if (postLIst != null && postLIst.size() > 0){
getCalloutResponse(postLIst);
}
}
@future(callout = true)
public static void getCalloutResponse(List<Id> postLIst){
postWrapper postWrapperObj;
List<postInformation> postInfoList = new List<postInformation>();
Map<Integer, String> postTitleMap = new Map<Integer, String>();
// Perform Rest Callout
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://jsonplaceholder.typicode.com/posts');
request.setMethod('GET');
HttpResponse response = http.send(request);
String responseBody = null;
if (response.getStatusCode() == 200){
responseBody = response.getBody();
System.debug('Response Received: '+ responseBody);
}
// If the REST API Response is not null, deserialize the Response and store id, postTitle in map
if (String.isNotBlank(responseBody)){
postWrapperObj = (postWrapper)System.JSON.deserialize(responseBody, postWrapper.class);
if (postWrapperObj != null) {
postInfoList = postWrapperObj.data;
}
if (postInfoList.size() > 0){
for(postInformation obj : postInfoList){
postTitleMap.put(obj.id, obj.postTitle);

}
}
}

List<Post__c> PstListToUpdate = new List<Post__c>();
List<Post__c> PostRecords = [Select Id, Id__c, Title__c from Post__c where Id IN: (postLIst)];
if (PostRecords != null && PostRecords.size() > 0){
for(Post__c PstObj : PostRecords){
if (postTitleMap != null && postTitleMap.containsKey(Integer.valueOf(PstObj.Id__c))){
PstObj.Title__c = postTitleMap.get(Integer.valueOf(PstObj.Id__c));
PstListToUpdate.add(PstObj);
}
}
}
if (PstListToUpdate.size() > 0)
update PstListToUpdate;
}
public class postWrapper{
public List<postInformation> data;
}
public class postInformation{
public Integer id;
public String postTitle;
}
}
Hi, 

I met a problem, now I create a custom profile with license "Custom Community Login", and also one pubilc site (Community), then I hope that I could download file (a link) with this profile, but it always failed. Could it work with this license ?

Thanks !