• Ankit Khiwansara 10
  • NEWBIE
  • 30 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies
import { LightningElement} from "lwc";

export default class ReactivityExample extends LightningElement {
  bool = true;
  number = 42;
  obj = { name: "John" };

  checkMutation() {
    this.bool = false; // Mutation detected

    this.number = 42; // No mutation detected: previous value is equal to the newly assigned value
    this.number = 43; // Mutation detected

    this.obj.name = "Bob"; // No mutation detect: 
  }
}
 
<template>
  <p>Boolean value : {bool}</p>
  <p>Number value : {number}</p>
  <p>Object value : {obj.name}</p>
  <lightning-button
    class="slds-var-m-around_small"
    variant="brand"
    label="Check Mutation"
    onclick={checkMutation}
  ></lightning-button>
</template>
In the above example, after clicking on checkMutation, my object property has been changed to Bob. I believe ideally it should not change and value should remain the same as John

Note - I am not using a track decorator here.

 
How to populate value in Contact.photoURL  

While executing below code, getting below error 

contact c = new contact (id = '0030o00002cWalwAAC');
c.photoURL = '/servlet/servlet.FileDownload?file=0150o00000HDM4s';
update c;    

Field is not writeable: Contact.PhotoUrl.

Could you please help me to execute below error.
 
HI Friends,

Could you please help me to create custom objects with tabs and pagelayout (without data) from one salesforce org to other salesforce org either with VSCODE or workbench
Hi Folks,
I am newbie on lightning and trying to learn custom validation on salesforce.
 
I want to validate email field value should only be rahul@gmail.com.For rest of the values , i want to populate error on component, but unable to do so. Could you please help me on that.
 
({
    newContactCreation: function (component, event, helper) {
        // Getting all fields and iterate them to check for validity
        var allValid = component.find('formFieldToValidate').reduce(function (validSoFar, inputCmp) {
            // Show help message if single field is invalid
            inputCmp.showHelpMessageIfInvalid();
            // Get the name of each field
            var name = inputCmp.get('v.name');
            // Check if name is emailField
            if (name == 'emailField') {
                // Getting the value of that field
                var value = inputCmp.get('v.value');
                // If value is not equal to rahul@gmail.com, add custom validation
                if (value != 'rahul@gmail.com') {
                    // Focus on that field to make custom validation work
                    //inputCmp.focus();
                    // Setting the custom validation
                    inputCmp.set('v.validity', { valid: false, badInput: true });
                    inputCmp.showHelpMessageIfInvalid();
                }
            }
            // Returning the final result of validations
            return validSoFar && inputCmp.get('v.validity').valid;
        }, true);

        if (allValid) {
            var action = component.get("c.createContact");
            action.setParams({
                con: component.get("v.con"),
                accountId: component.get("v.accountId")
            });

            action.setCallback(this, function (response) {
                var state = response.getState();
                if (state === "SUCCESS") {
                    windows.location.reload();
                } else {
                    alert("Problem in Data Fetching");
                }
            });

            $A.enqueueAction(action);
        }
    }
});



 
<aura:component controller="ElevenLCController">
    <aura:attribute name="accountId" type="String" />
    <aura:attribute name="con" type="Contact" default="{'Sobject' : 'Contact',
'FirstName' :'',
'LastNmae':'',
'Email':'',
'Phone':''}" />
    <div class="slds-p-around_x-small">
        <lightning:input required="true" aura:id="formFieldToValidate" label="First Name" value="{!v.con.FirstName}"
            type="text" messageWhenValueMissing="Please Enter First Name" />
        <lightning:input required="true" aura:id="formFieldToValidate" label="Last Name" value="{!v.con.LastName}"
            type="text" messageWhenValueMissing="Please Enter Last Name" />
        <lightning:input required="true" aura:id="formFieldToValidate" name="emailField" label="Email"
            value="{!v.con.Email}" type="Email" messageWhenBadInput="Enter Valid Email Id"
            messageWhenValueMissing="Please Enter Email" />
        <lightning:input required="true" aura:id="formFieldToValidate" label="Phone" value="{!v.con.Phone}"
            type="tel" />
    </div>
    <br />
    <lightning:button variant="brand" label="Create Contact" onclick="{!c.newContactCreation}" />
</aura:component>
I have before insert trigger on the Lead object to fetch the Territory__c object, where the Territory__c.PostalCode__c matches the Lead.PostalCode. The code fails uses the Apex Data Loader to insert 10,000 Lead records.

code block:

 for (Lead l : Trigger.new){
    if (l.PostalCode != null) {
        List<Territory__c> terrList = [SELECT Id FROM Territory__c WHERE PostalCode__c = :l.PostalCode];
        if(terrList.size() > 0) 
            l.Territory__c = terrList[0].Id; 
    }
}
Hello Friends,
I am preparing for DEV 1 certification . While going over sample questions, came accross below question. 

In which two trigger types a developer modify new sObjct Record that are obtained by trigger.new context.
A) After Insert
B) After Update
C) Before Update
D) Before Insert

I think ans for this is Before Update and Before Insert, 
As record firre by after triggers are readonly since it has completed DB operation.

Could you please confirm whether my understanding is correct.
Hello,

Could you please help me how to scan substring within the string.

Scanned String - Ankit

Example - My Name is Ankit -- Search found and answer should be True or Ankit.

Example - My Name is Ankita -- Search not found (As user searching for Ankit not Ankita) and answer should be False.

I am trying to use indexOfIgnoreCase(string) , but this is failing in second scenario.
Hello ,
I have created two lookup relationship on Contact object with Account Object. 
But i am unable to use SOQL query with one of the relationship. Can you please help me on this.
 Relationship Working with CustomAccount FieldRelationship not working with CustomContacts RelationshipUser-added imageUser-added image
Could you please help me to understand, as both the relationship from contact to account are same, why SOQL is working with other relationship and not with other one
import { LightningElement} from "lwc";

export default class ReactivityExample extends LightningElement {
  bool = true;
  number = 42;
  obj = { name: "John" };

  checkMutation() {
    this.bool = false; // Mutation detected

    this.number = 42; // No mutation detected: previous value is equal to the newly assigned value
    this.number = 43; // Mutation detected

    this.obj.name = "Bob"; // No mutation detect: 
  }
}
 
<template>
  <p>Boolean value : {bool}</p>
  <p>Number value : {number}</p>
  <p>Object value : {obj.name}</p>
  <lightning-button
    class="slds-var-m-around_small"
    variant="brand"
    label="Check Mutation"
    onclick={checkMutation}
  ></lightning-button>
</template>
In the above example, after clicking on checkMutation, my object property has been changed to Bob. I believe ideally it should not change and value should remain the same as John

Note - I am not using a track decorator here.

 
We have a custom object "Sample Request", when creating a record for the object "Sample Request", the option to select record type is displayed if the user has "Sample_Request_Select_Record_Type" permission set assigned to their profile : 
User-added image
This is working fine in SF classic as the following apex code is written :

  public Boolean getSelectRecordType(){
        list<PermissionSetAssignment> permissionSetAssignments = [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'Sample_Request_Select_Record_Type'];

        return (permissionSetAssignments.size() != 0);
    }

This code is called in the VF page :

<apex:outputPanel rendered="{!selectRecordType}"> Select a record type to use: &nbsp; <apex:selectList id="recordTypeId" value="{!recordTypeId}" size="1"> <apex:selectOptions value="{!rectypes}" /> </apex:selectList>

But when the same scenario is run in SF lightning, the users are not getting an option to select the record type :
User-added imageThe display record type section is missing because the lightning coding does not have the logic on the basis of "permission set" assignment. Can someone please help me with writing the lightning(@AuraEnabled) code for just this section of apex code :

public Boolean getSelectRecordType(){
        list<PermissionSetAssignment> permissionSetAssignments = [SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'Sample_Request_Select_Record_Type'];

        return (permissionSetAssignments.size() != 0);
    }

Really appreciate the help!! Thanks in advance.
Hi All,

LWC intellisense(autocomplete) is not working in HTML file for lwc in vs code. I have all the salesforce extensions installed. Also, I have tried reinstalling both vs cdoe, CLI and extensions too. Still the same issue.
Have been using this for so long but all of sudden, I was stuck with this yesterday. Can somebody assist here.

Thanks
Hello ,
I have created two lookup relationship on Contact object with Account Object. 
But i am unable to use SOQL query with one of the relationship. Can you please help me on this.
 Relationship Working with CustomAccount FieldRelationship not working with CustomContacts RelationshipUser-added imageUser-added image
Could you please help me to understand, as both the relationship from contact to account are same, why SOQL is working with other relationship and not with other one
https://developer.salesforce.com/trailhead/advanced_formulas/picklist_formulas
Has anyone managed to pass the challenge?
Gives error:
Challenge Not yet complete... here's what's wrong: 
The validation rule does not appear to be working correctly. Marking IsEscalated to true and Priority to Medium did not fire the validation rule.

Testing that same case myself (and some permuations) the Validation rule fires correctly I think...
Here is my validation formula
AND(
ISPICKVAL( Status , "Escalated"),
OR(
IsClosed,
IsClosedOnCreate,
NOT(ISPICKVAL( Priority , "High"))
)
)