• Martin Prokop
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 4
    Replies
Hello,
we like managed package named "Lightning Knowledge Search and Replace" which is mady by Salesforce Labs. 

We have decided to use it on our orgs (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FMl0XUAT).

Furthermore, we have a couple of questions.
1. Can you share sourcecode of this managed package with us (for example at git repository, etc...)? We would like to add some (from our point of view) usefull features. We will implement changes and give you codes - to allow you to share them with SF community.
2. If you can not give us sourcecodes, can you consider to implement some changes? Here is the list of features we considet to be useful:
a. Search field and Replacement field should accept block of code (not only one line). This can be usefull to update HTML version of articles RTA fields
b. Search results should display matches which will be replaced. This helps us to determine impact of replacement.
c. Allow to select articles by DataCategories or List of IDs. This allows us to change on selected articles.
d. Implement bulk call to run replacement over also translations of articles. On click to "replace", more batches can be runned. This allows us to change more translations in one run - this feature saves our time.

Thank you verry much,
Martin Prokop, 
SF Developer,
Avast software
Hello,
Could you help me please? I want to implement attaching files to Cases in SalesForce.
 
There is recomanded way which using apex:inputFile element, but I can’t use it, because on page I have to use more rerendering scopes.
 
So I decided to implement it via standard html input and action function with parameters (where content of file is passed in parameter to apex class).
 
Visualforce:
<apex:form id="techForm" enctype="multipart/form-data">
<apex:actionFunction name="fillAttachment" action="{!formController.FillAttachment}" reRender="attachmentsBlock">
<apex:param assignTo="{!formController.handleFileContent}" name="handleFileContent" value="" />
</apex:actionFunction>
<script type="text/javascript">
function check_extension(filename) {
var files = document.getElementById('attachment').files;                     
var file = files[0];
fillAttachment(file);
}
</script> 
<input type="file" accept=".gif, .jpg, .jpeg, .tif, .tiff, .png, .pdf" onChange="check_extension(this.value)" class="hidden" value="" filename="attachment" id="attachment" />
</form>

Apex Class:
public class ContactUsController {
    public  List<Attachment> attachments { get; set; }
    public String handleFileContent { get; set; }  
public void FillAttachment() {
if(this.handleFileContent != null && this.handleFileContent.length() > 0) {
Attachment toAttach = new Attachment(body = Blob.valueOf(this.handleFileContent));
this.attachments.add(toAttach);
}
}
}

The problem of this approach is that in this way, i got „Regex too complicated“ error.
  • So, I tried to check heap size (http://blog.jeffdouglas.com/2010/08/16/managing-the-heap-in-salesforce-com/), but it is no problem.
  • I also tryied to use Transcient method, but it does not work (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm).
  • Finnaly I tried to use future method, but it is static, so it is not possible for me to use it (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm).
 
I suggest that problem is that I exceed limit of view stat (https://developer.salesforce.com/forums/?id=906F0000000AsUHIA0)
 
Can you help me?
 
To Sum Up. Is there any way, how to send file from visualforce page using javascript and actionfunction to apex class? I can not use apex:imputFile because I have to use more rerender scopes on that page. I hope that there will be some workaround.
 
(I thinking about iframe page using apex:imputFile embedded to my page which handle uploading attachments and then via timpestamp-identifiers map it to relevant Case. But I think that it is "weird" way to upload files.)
 
Thank you for your answer.

Martin
I would like to know how to use Google Tag Manager with Any Community Template.
I did create Napili Community and found out how to use it with Google Analytics for click event on the custom button (involved using forceCommunity:analyticsInteraction).
BUT,
1. How to use 'Google tag Manager' with custom components on Any Community Template?
3. How to use 'Google Analytics' or 'Google tag Manager' Not with custom components, but with Template components?
3. SF Community allows to add 'Google Analytics' code to tag, but GTM code snippet needs to be added in the tag. How to accomplish that?
So far I was Not able to find Any information on Salesforce sites or by googling, so any help would be greatly appreciated?
Many thanks
  • August 28, 2017
  • Like
  • 2
I'm trying to get Google Tag Manager working with a Lightning Community. This involves getting a script and iframe into the site as per https://developers.google.com/tag-manager/quickstart

Script can't be put into the community head markup or branding css, so I created 2 Lightning components as follows:

Header component
<aura:component implements="forceCommunity:availableForAllPageTypes">
    <ltng:require scripts="{!$Resource.googletagmanager}"/>
</aura:component>

Body component
<aura:component implements="forceCommunity:availableForAllPageTypes">
    <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
    height="0" width="0" style="display:none;visibility:hidden"></iframe>
</aura:component>

The header component gives me an error as follows:

Uncaught Error: SecureElement does not allow access to async throws at https://myorg--livepreview.instance.force.com/mycommunity/s/sfsites/auraFW/javascript/egTJsAb7_Esngaq3zUvPDw/aura_prod.js:8:15

It looks like Lightning Components doesn't like the async attribute in the GTM script? If so, can I somehow get them to be friends? I can remove async from the script but I don't know how this will affect GTM. Anyone needed to do this before?
Hello,
Could you help me please? I want to implement attaching files to Cases in SalesForce.
 
There is recomanded way which using apex:inputFile element, but I can’t use it, because on page I have to use more rerendering scopes.
 
So I decided to implement it via standard html input and action function with parameters (where content of file is passed in parameter to apex class).
 
Visualforce:
<apex:form id="techForm" enctype="multipart/form-data">
<apex:actionFunction name="fillAttachment" action="{!formController.FillAttachment}" reRender="attachmentsBlock">
<apex:param assignTo="{!formController.handleFileContent}" name="handleFileContent" value="" />
</apex:actionFunction>
<script type="text/javascript">
function check_extension(filename) {
var files = document.getElementById('attachment').files;                     
var file = files[0];
fillAttachment(file);
}
</script> 
<input type="file" accept=".gif, .jpg, .jpeg, .tif, .tiff, .png, .pdf" onChange="check_extension(this.value)" class="hidden" value="" filename="attachment" id="attachment" />
</form>

Apex Class:
public class ContactUsController {
    public  List<Attachment> attachments { get; set; }
    public String handleFileContent { get; set; }  
public void FillAttachment() {
if(this.handleFileContent != null && this.handleFileContent.length() > 0) {
Attachment toAttach = new Attachment(body = Blob.valueOf(this.handleFileContent));
this.attachments.add(toAttach);
}
}
}

The problem of this approach is that in this way, i got „Regex too complicated“ error.
  • So, I tried to check heap size (http://blog.jeffdouglas.com/2010/08/16/managing-the-heap-in-salesforce-com/), but it is no problem.
  • I also tryied to use Transcient method, but it does not work (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm).
  • Finnaly I tried to use future method, but it is static, so it is not possible for me to use it (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm).
 
I suggest that problem is that I exceed limit of view stat (https://developer.salesforce.com/forums/?id=906F0000000AsUHIA0)
 
Can you help me?
 
To Sum Up. Is there any way, how to send file from visualforce page using javascript and actionfunction to apex class? I can not use apex:imputFile because I have to use more rerender scopes on that page. I hope that there will be some workaround.
 
(I thinking about iframe page using apex:imputFile embedded to my page which handle uploading attachments and then via timpestamp-identifiers map it to relevant Case. But I think that it is "weird" way to upload files.)
 
Thank you for your answer.

Martin

A couple of questions here:

 

1)  Does this URL Rewriter class look functional?  I thought I read that I didn't necessarily need the second generateURL function, but I'm not sure.

 

 

global with sharing class myRewriter implements Site.UrlRewriter {

String VIP_PAGE = '/VIP/';
String VIP_VISUALFORCE_PAGE = '/VIP?id=';

global PageReference mapRequestUrl(PageReference
myFriendlyUrl){
String url = myFriendlyUrl.getUrl();
if(url.startsWith(VIP_PAGE)){
String name = url.substring(VIP_PAGE.length(),
url.length());

Lead ld = [select id from Lead where XUniqueSearchId__c =:
name LIMIT 1];

return new PageReference(VIP_VISUALFORCE_PAGE + ld.id);
}

return null;
}

global List<PageReference> generateUrlFor(List<PageReference>
mySalesforceUrls){

return null;
}

}

 

 

2) What should the test class for this consist of?

 

Thank you in advance for any assistance you may be able to provide!

I would like to know how to use Google Tag Manager with Any Community Template.
I did create Napili Community and found out how to use it with Google Analytics for click event on the custom button (involved using forceCommunity:analyticsInteraction).
BUT,
1. How to use 'Google tag Manager' with custom components on Any Community Template?
3. How to use 'Google Analytics' or 'Google tag Manager' Not with custom components, but with Template components?
3. SF Community allows to add 'Google Analytics' code to tag, but GTM code snippet needs to be added in the tag. How to accomplish that?
So far I was Not able to find Any information on Salesforce sites or by googling, so any help would be greatly appreciated?
Many thanks
  • August 28, 2017
  • Like
  • 2