• Ashutosh Tripathi 72
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi 

I want to set a variable from an apex class at the beginning of the component load.
I guess connctedCallBack should work for me. but as I am using a promise call there it's not working there, though if I write static code there, it works for me. What can I do to achieve this motive?

Code sample that I am using:
 
connectedCallback() {
        console.log('connectedCallback Called! ');
        //console.log(this.bookMarked);
        console.log('Item Id: ' + this.itemId);
        console.log('Checking if already bookmarked'); IsBookmarked({ sItemId: this.itemId })
            .then(result => {
                console.log(result);
                console.log(this.buttonText);
                if (result) {
                    this.buttonText = "Remove from bookmark";
                    this.updateButtonText('Remove from bookmark!');
                }
                else {
                    this.buttonText = "Bookmark Me!"
                    this.updateButtonText('Bookmark Me!');
                }
                console.log(this.buttonText);
            })
            .error(error => {
                console.log('IsBookmarked Failed:' + error.body.message);
            });

    }

 
Hi 

I want to set a variable from an apex class at the beginning of the component load.
I guess connctedCallBack should work for me. but as I am using a promise call there it's not working there, though if I write static code there, it works for me. What can I do to achieve this motive?

Code sample that I am using:
 
connectedCallback() {
        console.log('connectedCallback Called! ');
        //console.log(this.bookMarked);
        console.log('Item Id: ' + this.itemId);
        console.log('Checking if already bookmarked'); IsBookmarked({ sItemId: this.itemId })
            .then(result => {
                console.log(result);
                console.log(this.buttonText);
                if (result) {
                    this.buttonText = "Remove from bookmark";
                    this.updateButtonText('Remove from bookmark!');
                }
                else {
                    this.buttonText = "Bookmark Me!"
                    this.updateButtonText('Bookmark Me!');
                }
                console.log(this.buttonText);
            })
            .error(error => {
                console.log('IsBookmarked Failed:' + error.body.message);
            });

    }

 
We are getting below error while runing local enviornment.

comand for local enviornment:
sfdx force:lightning:lwc:start

Error:
[0] [rollup] 'lightning/breadcrumbs' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\preview\preview.html, but could not be resolved – treating it as an external dependency
[0] [rollup] 'lightning/breadcrumb' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\preview\preview.html, but could not be resolved
– treating it as an external dependency
[0] [rollup] 'lightning/spinner' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\preview\preview.html, but could not be resolved – treating it as an external dependency
[view__preview.js] Done in 74090 ms
Writing d:\Users\<USER_FOLDER_NAME />>\Documents\GitHub\blocx-dev-lwc-v1.0.0-r1\.localdevserver/public/webruntime/view/8317de4485/dev/en_US/preview.js...
[view__mainLayout.js] Done in 202 ms
Writing d:\Users\<USER_FOLDER_NAME />>\Documents\GitHub\blocx-dev-lwc-v1.0.0-r1\.localdevserver/public/webruntime/view/67133358b1/dev/en_US/mainLayout.js...
[lds] Done in 789 ms
Error: Error compiling force/lds
    at Proxy.compile (C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@webruntime\compiler\dist\commonjs\compiler\compiler.js:231:15)
Caused by: Error: Could not resolve entry (force/lds)
    at error (C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\rollup\dist\rollup.js:3460:30)
    at C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\rollup\dist\rollup.js:21359:17
[0] [rollup] 'lightning/verticalNavigationSection' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\componentsPanel\componentsPanel.html, but could not be resolved – treating it as an external dependency
[0] [rollup] 'lightning/verticalNavigationItemIcon' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\componentsPanel\componentsPanel.html, but could not be resolved – treating it as an external dependency
[0] [rollup] 'lightning/icon' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\resourcesPanel\resourcesPanel.html, but could not be resolved – treating it as an external dependency
[0] [rollup] 'lightning/verticalNavigation' is imported by C:\Users\<USER_FOLDER_NAME />>\AppData\Local\sfdx\node_modules\@salesforce\lwc-dev-server\modules\localdevserver\componentsPanel\componentsPanel.html, but could not be resolved – treating it as an external dependency
[view__home.js] Done in 612 ms
Writing d:\Users\<USER_FOLDER_NAME />>\Documents\GitHub\blocx-dev-lwc-v1.0.0-r1\.localdevserver/public/webruntime/view/eaf2cb0c78/dev/en_US/home.js...
Hi,

I'm currently working with the "Discover Built-in XSS Protections in Force.com" Unit of Developer Advanced Trail. The point of the challenge is to edit the comments below each use of "{!sampleMergeField1}" to determine if is vulnerable to XSS. 

Based on the criteria found within the unit and in the guidelines in the Secure Coding Cross Site Scripting page for Built in Auto Encoding (All merge-fields are always auto HTML encoded provided they: do not occur within a <style> or <script> tag, AND do not occur within an apex tag with the escape='false' attribute) I came up with the following answers:
<apex:page controller="Built_In_XSS_Protections_Challenge" sidebar="false" tabStyle="Built_In_XSS_Protections_Challenge__tab">
<apex:sectionHeader title="Built-In XSS Protections Challenge" />
<apex:form >
    <apex:pageBlock >
        <c:Classic_Error />
        <apex:pageMessages />      
        <apex:pageBlockSection title="Demo" columns="1" id="tableBlock">          
            
            <apex:outputText value="{!sampleMergeField1}"/>
            <!-- sampleMergeField1 is vulnerable to XSS: NO -->


            <apex:outputText value="{!sampleMergeField2}" escape="false"/>
            <!-- sampleMergeField2 is vulnerable to XSS: YES -->


            <apex:outputText >
                {!sampleMergeField3}
            </apex:outputText>
            <!-- sampleMergeField3 is vulnerable to XSS: NO -->
       
       
            <style>
                .foo {
                    color: #{!sampleMergeField4};
                }
            </style>
            <!-- sampleMergeField4 is vulnerable to XSS: YES -->
             
            
            {!sampleMergeField5}
            <!-- sampleMergeField5 is vulnerable to XSS: NO -->
            
            
            <script>
                var x = '{!sampleMergeField6}';
            </script>
            <!-- sampleMergeField6 is vulnerable to XSS: YES -->
            
            
            <apex:outputLabel value="{!sampleMergeField7}" escape="false"/>
            <!-- sampleMergeField7 is vulnerable to XSS: YES -->
            
       
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Code links" columns="1">
            <apex:outputPanel >
                <ul>
                    <li><c:codeLink type="Visualforce" namespace="security_thail" name="Built_In_XSS_Protections_Challenge" description="Visualforce Page"/></li>            
                    <li><c:codeLink type="Apex" namespace="security_thail" name="Built_In_XSS_Protections_Challenge" description="Apex Controller"/></li>
                </ul>
            </apex:outputPanel>        
        </apex:pageBlockSection>        
    </apex:pageBlock>          
</apex:form>

But everytime y check the challenge, the same message is displayed:

User-added image

I already checked that I am pointing to the right playground. 

If you can check it and help find where I am going wrong I would be thankful.

Thanks