• hksl
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 2
    Replies
I am new to salesforce, coming from C#.net experience.
Lightning.
Trying to isolate some setCallBack-related-code into helper function
to call from cases of switch statement in another helper function.
During execution, processing never gets into execSetCallBack() function (see below).
No errors generated.
What I am doing wrong?
Many thanks

Ma

Helper:

doInitHelper : function(component,event,helper) {
   var objtype = component.get("v.ObjectType");
   switch (objType)
   {
        case "MyObj1":
                 var parm1 = "c.getMyValue";  ////// to call Apex controller function  getMyValue(recordId)
                 var action = component.get(parm1);  
                 action.setParams({ "recordId" : recId});                
                 action.setCallback(this, function(response) 
                 {                                   
                     var state = response.getState(); 
                     if (state === "SUCCESS") 
                     { 
                         var rv = response.getReturnValue();                                                
                       
                          helper.myFunction2("strvalue1", "strvalue2"); 
                     }
                    else if (state === "ERROR") 
                    {
                        alert('Error : ' + JSON.stringify(errors));
                    }     
         }); 
        $A.enqueueAction(action);                        

        // better to call helper function instead (that includes code above) :   helper.execSetCallBack( parm1, other params .... )
         
        break;
        // ----------------------------------------
        case "MyObj2":

            // need to repeat whole   action.SetCallBack   section again  . . .

            // better to call helper function instead :   helper.execSetCallBack( parm1, other params .... )
       
            break;
    }
}

// ====================

execSetCallBack : function(parm1, recId, parmStrValue1, parmStrValue2) {
{
     alert("in execSetCallBack ");    //----> NEVER GET HERE if calling this function ????? <-------

     var action = component.get(parm1.toString());     
     action.setParams({ "recordId" : recId});                
     action.setCallback(this, function(response) 
     {                                   
          var state = response.getState(); 
          if (state === "SUCCESS") 
          { 
               var rv = response.getReturnValue();                                                
                       
               helper.myFunction2( parmStrValue1, parmStrValue2 ); 
           }
           else if (state === "ERROR") 
           {
                alert('Error : ' + JSON.stringify(errors));
           }     
     }); 
     $A.enqueueAction(action);

}
  • September 26, 2017
  • Like
  • 0
Is it possible to make apex calls from <head> section of Lightning Community (Napili template)?
We need to get "User Id" inside <head> section to set custom dimension in Google Analytics.
Tried following script that does not work:

<script>
  {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
  {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
    
  .....code provided by Google Analitics here to integrate ........    

  ga('create', '...unique id provided by Google Analitics here...', 'auto');     

  var user = sforce.connection.getUserInfo();  // apex
  console.log(user);

 //need to call:  ga("set", "dimension1", user);  
 
  ga('send', 'pageview');
    
</script>

Any suggestions will be greatly appreciated.
Thank you
  • September 13, 2017
  • Like
  • 0
To integrate SF Community with Google Tag Manager, GTM provides two code snippets to be installed into 'head' and 'body' tag of the Community site. SF Community allows to install code-snippet into 'head' tag, but How to install second code-snippet into 'body' tag of the Community (for example if Napili Template is used) ? Many thanks
  • August 31, 2017
  • Like
  • 1
To integrate SF Community with Google Tag Manager, GTM provides 2 code snippets to be installed into 'head' and 'body' tag of the Community site. SF Community allows to install code-snippet into 'head' tag,
but
How to install second code-snippet into 'body' tag of the Community, when community TEMPLATE is used ?
Many thanks
  • August 30, 2017
  • Like
  • 0
Is it possible to Access Events triggered by Napili Template standard components (Lightning Community)?
I need to call forceCommunity_analyticsInteraction on onclick event for standard components on Napili Template. Many thanks
  • August 29, 2017
  • Like
  • 0
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 am a beginner in building SalesForce Communities.
Dev org.
I am trying to integrate my community with Google Analytics.
So far Google Analytics does Not see my SF Community.

Could below warnings be the reason? If 'yes' - what to do about it?  Many thanks.
--------------
I've created Lightning Community.
I went to Community Workspaces -> Builder -> Settings -> Advanced
and entered my "Google Analytics Tracking Code"
and entered Head Markup 
<script>
  .....
</script>

I am getting warning:

Check Your Head Markup
With the "Enable Stricter Content Security Policy for Lightning Components in Communities" critical update in sandbox and DE orgs, you have control over whether to enforce stricter CSP. When stricter CSP is activated, some of your existing head markup may not work correctly. Test your markup in your sandbox or DE orgs first before activating in live orgs in a future release.
For security purposes, we allow only the following tags, attributes, and values in the <head> section:
<base>: href, target
<link>: as, charset, crossorigin, disabled, href, hreflang, id, import, integrity, media, rel (only values of alternate, apple-touch-icon, apple-touch-icon-precomposed, apple-touch-startup-image, author, bookmark, external, help, icon, license, manifest, mask-icon, next, nofollow, noopener, noreferrer, pingback, prefetch, preload, prev, search, shortcut icon, stylesheet, and tag), relList, rev, sheet, sizes, target, title, type
<meta>: charset, content, http-equiv (only values of cleartype, content-type, content-language, and default-style), name, scheme
<title>: No attributes allowed

As i understand so far this warning has to do with "Stricter Content Security Policy for Lightning Components in Communities"
https://releasenotes.docs.salesforce.com/en-us/summer17/release-notes/rn_lightning_stricter_csp.htm
--------
AND warning "When activated, the Enable Stricter CSP for Lightning Components in Communities critical update might affect script tag behavior."
related to <script> tag in the Google Analytics code.
---------
"Critical Updates" page has:

Enable Stricter Content Security Policy for Lightning Components
    The Lightning Component framework already uses CSP, which is a W3C standard, to control the source of content that can be loaded on a page. This critical update enables stricter Content Security Policy (CSP) to mitigate the risk of cross-site scripting attacks. Stricter CSP is enforced only in sandboxes and Developer Edition orgs.    
    Activated

Enable Stricter Content Security Policy for Lightning Components in Communities    
    This critical update enables stricter Content Security Policy (CSP) in sandboxes and Developer Edition orgs for Lightning communities only. The Lightning Component framework already uses CSP, which is a W3C standard, to control the source of content that can be loaded on a page. This update enables stricter CSP to mitigate the risk of cross-site scripting attacks.    
    Not Activated
---------------------------------------------
 
  • August 21, 2017
  • Like
  • 0
I am going through "Build a Lightning App with the Lightning Design System" project in Trailhead.
In the AccountList.cmp component there is below code that creates "Delete" button in each row in the table created in that project.
As exercise states - click on any Delete botton should dsplay dialog box. It does Not happen.
So far I was not able to find out why, please help.   Many thanks
<form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!account.Name}" class="account-name" />
              <!--
                Use a Lightning Base Component
                To display an icon next to the label
               -->
              <lightning:button label="Delete"
                                iconName="utility:delete"
                                iconPosition="left"
                                variant="destructive"
                                />
            </form>

------------------ in the javascript controller AccountListControlle.js there is following code:
deleteAccount: function(component, event, helper) {
      
    // Prevent the form from getting submitted
    event.preventDefault();

    // Get the value from the field that's in the form
    var accountName = event.target.getElementsByClassName('account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)'); --- THIS LINE DOES NOT WORK, DIALOG BOX DOES NOT SHOW UP. 
  }
  • May 24, 2017
  • Like
  • 0
Where I can find video (recording) of "Webinar: Intro to Force.com" that took place on February 24, 2017 ? 
Thank you
  • March 03, 2017
  • Like
  • 0
To integrate SF Community with Google Tag Manager, GTM provides two code snippets to be installed into 'head' and 'body' tag of the Community site. SF Community allows to install code-snippet into 'head' tag, but How to install second code-snippet into 'body' tag of the Community (for example if Napili Template is used) ? Many thanks
  • August 31, 2017
  • Like
  • 1
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
Is it possible to make apex calls from <head> section of Lightning Community (Napili template)?
We need to get "User Id" inside <head> section to set custom dimension in Google Analytics.
Tried following script that does not work:

<script>
  {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
  {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
    
  .....code provided by Google Analitics here to integrate ........    

  ga('create', '...unique id provided by Google Analitics here...', 'auto');     

  var user = sforce.connection.getUserInfo();  // apex
  console.log(user);

 //need to call:  ga("set", "dimension1", user);  
 
  ga('send', 'pageview');
    
</script>

Any suggestions will be greatly appreciated.
Thank you
  • September 13, 2017
  • Like
  • 0
I am going through "Build a Lightning App with the Lightning Design System" project in Trailhead.
In the AccountList.cmp component there is below code that creates "Delete" button in each row in the table created in that project.
As exercise states - click on any Delete botton should dsplay dialog box. It does Not happen.
So far I was not able to find out why, please help.   Many thanks
<form class="account-form" onsubmit="{!c.deleteAccount}">
              <input type="hidden" value="{!account.Name}" class="account-name" />
              <!--
                Use a Lightning Base Component
                To display an icon next to the label
               -->
              <lightning:button label="Delete"
                                iconName="utility:delete"
                                iconPosition="left"
                                variant="destructive"
                                />
            </form>

------------------ in the javascript controller AccountListControlle.js there is following code:
deleteAccount: function(component, event, helper) {
      
    // Prevent the form from getting submitted
    event.preventDefault();

    // Get the value from the field that's in the form
    var accountName = event.target.getElementsByClassName('account-name')[0].value;
    confirm('Delete the ' + accountName + ' account? (don’t worry, this won’t actually work!)'); --- THIS LINE DOES NOT WORK, DIALOG BOX DOES NOT SHOW UP. 
  }
  • May 24, 2017
  • Like
  • 0