+ Start a Discussion
Stuart FlemingStuart Fleming 

How to complete LTNG_SecureFilters_Challenge

I am stuck on the https://trailhead.salesforce.com/modules/security-for-lightning-components/units/secure-your-lightning-java-script-code challenge.
After searching on the internet, I am unable to find a solution.  I found a link https://developer.salesforce.com/forums/?id=9060G000000UbhwQAC but I am not sure what solution in it works.  (And I found another web page referring this same url saying "Jeff" had found a solution..but it did not work for me.  Here is what Jeff first says:
Trying securing the description instead:   secureFilters.html(results[i].Description__c)

I tried that and get this message:  
Challenge Not yet complete... here's what's wrong: 
The 'LTNG_SecureFilters_Challenge' component does not appear to be requiring the secureFilters resource.

Further in the post the person who asked the question says this:   "That worked. Thanks."
And then he summarizes and says would this be OK:

​secureFilters.html(results)  

And Jeff replies, "Correct".  

So I tried doing this:  
                var results =   response.getReturnValue()  ;
                secureFilters.html(results) ;    
And this created an error.....
And I tried this (thinking that maybe it needs to be passed to a variable) :
                var results =   response.getReturnValue()  ;
                results =  secureFilters.html(results) ;
And this created an error.....

Can anyone please help?

Thank you,
Stuart

Best Answer chosen by Stuart Fleming
Stuart FlemingStuart Fleming
I guess I will give myself an atta-boy.  I found the solution.

1.  At the top of the LTNG_SecureFilters_Demo.cmp file was a reference to 
    <ltng:require scripts="{!$Resource.DemoSecureFilters}" />

I had not added a reference to the "{!$Resource.DemoSecureFilters}" in the  LTNG_SecureFilters_Challenge.cmp.   So I added this 

    <ltng:require scripts="{!$Resource.DemoSecureFilters}" />  

to the top of the  LTNG_SecureFilters_Challenge.cmp.  However,  using the DemoSecureFilters in the LTNG_SecureFilters_Challenge.cmp file did not work.  
 
I had already downloaded the github resource and named it securefilters.js, and tried updating the LTNG_SecureFilters_Challenge.cmp. file reference to 
<ltng:require scripts="{!$Resource.securefilters}" />

This passed the challenge

So the solution is:
1.  download the github js library (mentioned in the trailhead). as a static resource.  Name it securefilters.js
2. Update the LTNG_SecureFilters_Challenge.cmp to reference javascript library
    <ltng:require scripts="{!$Resource.securefilters}" />
3.  Change the results[i].Description__c to
  secureFilters.html(results[i].Description__c )

All Answers

Stuart FlemingStuart Fleming
I guess I will give myself an atta-boy.  I found the solution.

1.  At the top of the LTNG_SecureFilters_Demo.cmp file was a reference to 
    <ltng:require scripts="{!$Resource.DemoSecureFilters}" />

I had not added a reference to the "{!$Resource.DemoSecureFilters}" in the  LTNG_SecureFilters_Challenge.cmp.   So I added this 

    <ltng:require scripts="{!$Resource.DemoSecureFilters}" />  

to the top of the  LTNG_SecureFilters_Challenge.cmp.  However,  using the DemoSecureFilters in the LTNG_SecureFilters_Challenge.cmp file did not work.  
 
I had already downloaded the github resource and named it securefilters.js, and tried updating the LTNG_SecureFilters_Challenge.cmp. file reference to 
<ltng:require scripts="{!$Resource.securefilters}" />

This passed the challenge

So the solution is:
1.  download the github js library (mentioned in the trailhead). as a static resource.  Name it securefilters.js
2. Update the LTNG_SecureFilters_Challenge.cmp to reference javascript library
    <ltng:require scripts="{!$Resource.securefilters}" />
3.  Change the results[i].Description__c to
  secureFilters.html(results[i].Description__c )
This was selected as the best answer
Francis CrumpFrancis Crump
Nice thanks that worked for me.