• Soundhariyaa M
  • NEWBIE
  • 100 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 11
    Replies
What is the best way to prevent duplicate records from being created in an object in Salesforce
Hi,

I'm new to Salesforce.
Can anyone explain me What is Co-terming, Short and Forward Co-terming and Proration in Quoting.

I come across these terms often.Though I refer many blogs for understanding this concept.I'm not able to get the concept.

Can anyone help me understand this concept.

Thanks in advance!

 
Hi,

Controller functions:

A:function(component, event, helper){
   helper.getExample(component,event);
},
B:function(component, event, helper){
   helper.getExample(component,event,parameters);
},
C:function (component, event, helper){
   helper.getExample(component,event)
},
D:function (component, event, helper)//which is actually a search function
{
    helper.getExample(component,event,searchString);
},
E:function(component, event, helper){
   helper.getExample(component,event,searchString,numberofrecords);
}

Helper function:

getExample:function(component,parameters,searchString,numberofrecords)
{
},

My doubt is in A (Controller function),we are passing event but in helper function we don't have event parameter in function declaration.
In D (Controller function),searchString is passed to helper as third argument and it is getting assigned correctly to  searchString without getting assigned to parameters.How???

In C (Controller function), event is passed but we don't have event in helper function.

And the code is working fine without any errors?!

How is this even possible?
I guess I'm lacking some concept.Could you help me understand this?!
 
Hi,

Suppose I have 

a:funtion(component,event)
{
},
b:function(component,event,page)
{
}
And I wanted to call b() from a() 
where page is a Integer.
How can I do this?
I tried the one given below but it didn't work
a:funtion(component,event)
{
    this.b(component,event,1);
},
b:function(component,event,page)
{
}
Can anyone help me
Hi,

Suppose I have 

a:funtion(component,event)
{
},
b:function(component,event,page)
{
}
And I wanted to call b() from a() 
where page is a Integer.
How can I do this?
I tried the one given below but it didn't work
a:funtion(component,event)
{
    this.b(component,event,1);
},
b:function(component,event,page)
{
}
 
public with sharing class searchProduct2Controller 
{
   
    @AuraEnabled
    public static List < Product2 > fetchProduct2(String searchKeyWord) {
        String searchKey = searchKeyWord + '%';
        List < Product2 > returnList = new List < Product2 > ();
        List < Product2 > lstOfProduct2 = [select Name,ProductCode,Price__c from Product2
                                           where Name LIKE: searchKey LIMIT 500];
        
        for (Product2 prod: lstOfProduct2) {
            returnList.add(prod);
        }
        return returnList;
    }
    
    @AuraEnabled
    public static List<AWSWrapper> awsData(){
        
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://s3.amazonaws.com/targetx-sfdc-interview/packages.json');
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        return (List<AWSWrapper>)JSON.deserialize(res.getBody().replaceAll('__c','_Tempc'), List<AWSWrapper>.class);
    }
}

In awsData(), in req.setEndpoint('https://s3.amazonaws.com/targetx-sfdc-interview/packages.json'); I have given the URL directly here.
How can I assign it to a configurable variable and access that variable here so that whenever URL changes in future, I can change only there and not to make any modifications to the code?
 
This is my lightning component User-added imageWhen I click edit button, the modal appears,
User-added imageWhen I click the save button here in this modal, I want search function to be called because the changes I make here is not getting reflected in the table and it is getting reflected only when search button is clicked..
How can I do this?
Apex class:
public with sharing class searchProduct2Controller {
 
 @AuraEnabled
 public static List < Product2 > fetchProduct2(String searchKeyWord) {
  String searchKey = searchKeyWord + '%';
  List < Product2 > returnList = new List < Product2 > ();
  List < Product2 > lstOfProduct2 = [select Name,ProductCode,Price__c from Product2
                                   where Name LIKE: searchKey LIMIT 500];
 
  for (Product2 prod: lstOfProduct2) {
   returnList.add(prod);
  }
  return returnList;
 }
}
searchProduct2.cmp
<aura:component controller="searchProduct2Controller" implements="flexipage:availableForAllPageTypes" access="global" > 
    <aura:dependency resource="markup://force:editRecord" type="EVENT" />    
    <aura:handler event="force:refreshView" action="{!c.Search}" />
    
    <!-- CREATE ATTRIBUTE/VARIABLE-->
    <aura:attribute name="searchResult" type="List" description="use for store and display Product2 list return from server"/>
    <aura:attribute name="searchKeyword" type="String" description="use for store user search input"/>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <aura:attribute name="TotalNumberOfRecord" type="integer" default="0" description="use for display Number of records"/>
    
    <!-- SHOW LOADING SPINNER--> 
    <lightning:spinner variant="brand" size="large" aura:id="Id_spinner" class="slds-hide" />
    <lightning:card title="Products">

       <!-- SEARCH INPUT AND SEARCH BUTTON--> 
        <lightning:layout>
            <lightning:layoutItem size="3" padding="around-small">
                <lightning:input value="{!v.searchKeyword}"
                                 required="true"
                                 placeholder="search Products.."
                                 aura:id="searchField"
                                 label="Product Name"/>
            </lightning:layoutItem>
            <lightning:layoutItem size="3" padding="around-small">
                <lightning:button onclick="{!c.Search}"
                                  variant="brand"
                                  label="Search"
                                  iconName="utility:search"/> 
            </lightning:layoutItem>
        </lightning:layout>
       
        <!-- TOTAL RECORDS BADGES--> 
       
            <lightning:badge label="{!v.TotalNumberOfRecord}" />
        
        
        <!-- ERROR MESSAGE IF NOT RECORDS FOUND--> 
        <aura:if isTrue="{!v.Message}">
            <div class="slds-notify_container slds-is-relative">
                <div class="slds-notify slds-notify_toast slds-theme_error" role="alert">
                    <div class="slds-notify__content">
                        <h2 class="slds-text-heading_small">No Records Found...</h2>
                    </div>
                </div>
            </div>
        </aura:if>
       
        <!-- TABLE CONTENT--> 
        <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
            <thead>
                <tr class="slds-text-title_caps">
                    <th scope="col">
                        <div class="slds-truncate" title="S.no">S.no</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Product Name">Product2 Name</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Type">Product Code</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Industry">Price</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title="Action">Action</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title="Action">Mark for Deletion</div>
                    </th>
                </tr>
            </thead>
            <tbody> 
                <!--### display all records of searchResult attribute by aura:iteration ###-->
                    <aura:iteration items="{!v.searchResult}" var="pr" indexVar="count">
                        <tr>
                            <td>
                                <div class="slds-truncate">{!count + 1}</div>
                            </td>
                            <td>
                                <div class="slds-truncate">{!pr.Name}</div>
                            </td>
                            <td>
                                <div class="slds-truncate">{!pr.ProductCode}</div>
                            </td>
                            <td>
                                <div class="slds-truncate">{!pr.Price__c}</div>
                            </td>
                            <td>
                                <button class="slds-button slds-button_brand" onclick="{!c.edit}" id="{!pr.Id}">Edit</button>
                            </td>
                             <td>                        	
                            <div class="slds-checkbox">
                                <input type="checkbox" name="chk" id="{!pr.Id}" onchange="{!c.getSelectedProducts}"/>                            
                                <label class="slds-checkbox__label" for="{!pr.Id}">
                                    <span class="slds-checkbox_faux"></span>                                
                                </label>
                            </div>                                           
                            </td>
                        </tr>
                    </aura:iteration>              
           </tbody>
        </table>
        
        <aura:set attribute="actions">
            <!-- New button added -->
            <lightning:button variant="brand" label="New Product" onclick="{!c.newContact}" />
            <!-- Delete button added -->
            <lightning:button variant="destructive" label="Delete" onclick="{!c.deleteContacts}" />
        </aura:set>
    </lightning:card>
	
</aura:component>

Controller
({
    Search: function(component, event, helper) {
        var searchField = component.find('searchField');
        var isValueMissing = searchField.get('v.validity').valueMissing;
        if(isValueMissing) {
            searchField.showHelpMessageIfInvalid();
            searchField.focus();
        }else{
            helper.SearchHelper(component, event);
        }
    },
    edit: function(component, event, helper){
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": event.target.id
       });
       editRecordEvent.fire();
    }
})

Helper
({
    SearchHelper: function(component, event) {
        // show spinner message
         component.find("Id_spinner").set("v.class" , 'slds-show');
        var action = component.get("c.fetchProduct2");
        action.setParams({
            'searchKeyWord': component.get("v.searchKeyword")
        });
        action.setCallback(this, function(response) {
           // hide spinner when response coming from server 
            component.find("Id_spinner").set("v.class" , 'slds-hide');
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                
                // if storeResponse size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                } else {
                    component.set("v.Message", false);
                }
                
                // set numberOfRecord attribute value with length of return value from server
                component.set("v.TotalNumberOfRecord", storeResponse.length);
                
                // set searchResult list with return value from server.
                component.set("v.searchResult", storeResponse); 
                
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
})

​​​​​​​​​​​​​​
 
This is the Error I get when I try to create a new project "HelloWorldLightningWebComponent" in Visual Studio Code

Starting SFDX: Create Project
14:33:27.962 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\msoundhariya\Desktop\Salesforce --template standard
ERROR running force:project:create:  Command failed with exit code 1: npm root -g --prefix c:\Users\msoundhariya\Desktop\Salesforce\.yo-repository --loglevel error
'npm' is not recognized as an internal or external command,
operable program or batch file.
14:33:29.121 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\msoundhariya\Desktop\Salesforce --template standard
 ended with exit code 1

Could anyone help to resolve this ?!
Thanks in Advance
The scenario is,
I need to send email alerts to Sales Director in the org [ in this case, it is my mail id] whenever opportunity stage update takes place and
In Approval process, mail has to be sent requesting approval.

For email alert on stage updates, I used workflow.
My workflow and Approval Process were working properly but suddenly I'm not getting email today??

I donno why suddenly it is not working?

Could anyone  help to figure this out..

Thanks in advance
I tried creating new opportunity, but it is showin me this errorUser-added imageNow, what should I do to create a new opportunity?

Thanks in Advance!!
The scenario is:

I need to send CEO Closed WON Report in Email every Week.

I created the report and when I subscribed it and tried sending report mail to me[myself and not other user], I'm getting this error.
I'm using Developer Edition.

User-added imageI'm not able to figure out how to resolve this..

Thanks in Advance!
I am completely new to Triggers.
My scenario is:
If "Call Completed" checkbox in Opportunity field is checked then "Stage" field in Opportunity Object must change to "Quotation".

Could anyone tell me how to acheive this?
I'm completely blank..
I would be glad if you suggest me how to master Triggers in Salesforce too.


Thanks in Advance !
 
I have a "Customer Accept/Reject"  picklist value in Quote object where Accept and Reject are the picklist values.
So, when Accept is selected in "Customer Accept/Reject" , "Quote Stage" in Quote must be changed to "Customer Approved" and "Stage" field in Opportunity must be changed to "Closed won".
When Reject is selected in "Customer Accept/Reject", "Stage" field in Opportunity must be changed to "Negotiation".

I used Process Builder to do this.

User-added image
User-added imageUser-added imageUser-added imageUser-added image

When I do this, when Accept is selected in "Customer Accept/Reject" , "Quote Stage" in Quote is changing to "Customer Approved" and "Stage" field in Opportunity is changing to "Closed won". And first criteria is working perfectly.

But,When Reject is selected in "Customer Accept/Reject", "Stage" field in Opportunity is not changing to "Negotiation".

I am not getting how in same process builder, first criteria is working and second criteria is not working.

Could you please help me to resolve this problem?

Thanks in advance!
I have created apex rest service and  I am calling it from workbench rest explorer,but I am getting an error

Class :

@RestResource(urlMapping='/casesTest/*')
global with sharing class CaseManager {

    @HttpGet
    global static Case getCaseById(){
        RestRequest request=RestContext.request;
       String caseId= request.requestURI.substring(request.requestURI.lastIndexOf('/')+1);
       Case result= [Select CaseNumber,Subject,Status,Priority From Case where Id=:caseId];
        return result;
    }
}

And then when

I am giving the url as 
/services/apexrequest/casesTest/5002w000004RLjF
5002w000004RLjF is the caseId

I'm getting the following error :
User-added image
User-added image

Can some body please help me,why is this error
or  
with the steps to followed..

Thanks in Advance.
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: VVDBTMLV
What is the best way to prevent duplicate records from being created in an object in Salesforce
Hi,

I'm new to Salesforce.
Can anyone explain me What is Co-terming, Short and Forward Co-terming and Proration in Quoting.

I come across these terms often.Though I refer many blogs for understanding this concept.I'm not able to get the concept.

Can anyone help me understand this concept.

Thanks in advance!

 
Hi,

Suppose I have 

a:funtion(component,event)
{
},
b:function(component,event,page)
{
}
And I wanted to call b() from a() 
where page is a Integer.
How can I do this?
I tried the one given below but it didn't work
a:funtion(component,event)
{
    this.b(component,event,1);
},
b:function(component,event,page)
{
}
Can anyone help me
public with sharing class searchProduct2Controller 
{
   
    @AuraEnabled
    public static List < Product2 > fetchProduct2(String searchKeyWord) {
        String searchKey = searchKeyWord + '%';
        List < Product2 > returnList = new List < Product2 > ();
        List < Product2 > lstOfProduct2 = [select Name,ProductCode,Price__c from Product2
                                           where Name LIKE: searchKey LIMIT 500];
        
        for (Product2 prod: lstOfProduct2) {
            returnList.add(prod);
        }
        return returnList;
    }
    
    @AuraEnabled
    public static List<AWSWrapper> awsData(){
        
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://s3.amazonaws.com/targetx-sfdc-interview/packages.json');
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        return (List<AWSWrapper>)JSON.deserialize(res.getBody().replaceAll('__c','_Tempc'), List<AWSWrapper>.class);
    }
}

In awsData(), in req.setEndpoint('https://s3.amazonaws.com/targetx-sfdc-interview/packages.json'); I have given the URL directly here.
How can I assign it to a configurable variable and access that variable here so that whenever URL changes in future, I can change only there and not to make any modifications to the code?
 
This is my lightning component User-added imageWhen I click edit button, the modal appears,
User-added imageWhen I click the save button here in this modal, I want search function to be called because the changes I make here is not getting reflected in the table and it is getting reflected only when search button is clicked..
How can I do this?
Apex class:
public with sharing class searchProduct2Controller {
 
 @AuraEnabled
 public static List < Product2 > fetchProduct2(String searchKeyWord) {
  String searchKey = searchKeyWord + '%';
  List < Product2 > returnList = new List < Product2 > ();
  List < Product2 > lstOfProduct2 = [select Name,ProductCode,Price__c from Product2
                                   where Name LIKE: searchKey LIMIT 500];
 
  for (Product2 prod: lstOfProduct2) {
   returnList.add(prod);
  }
  return returnList;
 }
}
searchProduct2.cmp
<aura:component controller="searchProduct2Controller" implements="flexipage:availableForAllPageTypes" access="global" > 
    <aura:dependency resource="markup://force:editRecord" type="EVENT" />    
    <aura:handler event="force:refreshView" action="{!c.Search}" />
    
    <!-- CREATE ATTRIBUTE/VARIABLE-->
    <aura:attribute name="searchResult" type="List" description="use for store and display Product2 list return from server"/>
    <aura:attribute name="searchKeyword" type="String" description="use for store user search input"/>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <aura:attribute name="TotalNumberOfRecord" type="integer" default="0" description="use for display Number of records"/>
    
    <!-- SHOW LOADING SPINNER--> 
    <lightning:spinner variant="brand" size="large" aura:id="Id_spinner" class="slds-hide" />
    <lightning:card title="Products">

       <!-- SEARCH INPUT AND SEARCH BUTTON--> 
        <lightning:layout>
            <lightning:layoutItem size="3" padding="around-small">
                <lightning:input value="{!v.searchKeyword}"
                                 required="true"
                                 placeholder="search Products.."
                                 aura:id="searchField"
                                 label="Product Name"/>
            </lightning:layoutItem>
            <lightning:layoutItem size="3" padding="around-small">
                <lightning:button onclick="{!c.Search}"
                                  variant="brand"
                                  label="Search"
                                  iconName="utility:search"/> 
            </lightning:layoutItem>
        </lightning:layout>
       
        <!-- TOTAL RECORDS BADGES--> 
       
            <lightning:badge label="{!v.TotalNumberOfRecord}" />
        
        
        <!-- ERROR MESSAGE IF NOT RECORDS FOUND--> 
        <aura:if isTrue="{!v.Message}">
            <div class="slds-notify_container slds-is-relative">
                <div class="slds-notify slds-notify_toast slds-theme_error" role="alert">
                    <div class="slds-notify__content">
                        <h2 class="slds-text-heading_small">No Records Found...</h2>
                    </div>
                </div>
            </div>
        </aura:if>
       
        <!-- TABLE CONTENT--> 
        <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
            <thead>
                <tr class="slds-text-title_caps">
                    <th scope="col">
                        <div class="slds-truncate" title="S.no">S.no</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Product Name">Product2 Name</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Type">Product Code</div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="Industry">Price</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title="Action">Action</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title="Action">Mark for Deletion</div>
                    </th>
                </tr>
            </thead>
            <tbody> 
                <!--### display all records of searchResult attribute by aura:iteration ###-->
                    <aura:iteration items="{!v.searchResult}" var="pr" indexVar="count">
                        <tr>
                            <td>
                                <div class="slds-truncate">{!count + 1}</div>
                            </td>
                            <td>
                                <div class="slds-truncate">{!pr.Name}</div>
                            </td>
                            <td>
                                <div class="slds-truncate">{!pr.ProductCode}</div>
                            </td>
                            <td>
                                <div class="slds-truncate">{!pr.Price__c}</div>
                            </td>
                            <td>
                                <button class="slds-button slds-button_brand" onclick="{!c.edit}" id="{!pr.Id}">Edit</button>
                            </td>
                             <td>                        	
                            <div class="slds-checkbox">
                                <input type="checkbox" name="chk" id="{!pr.Id}" onchange="{!c.getSelectedProducts}"/>                            
                                <label class="slds-checkbox__label" for="{!pr.Id}">
                                    <span class="slds-checkbox_faux"></span>                                
                                </label>
                            </div>                                           
                            </td>
                        </tr>
                    </aura:iteration>              
           </tbody>
        </table>
        
        <aura:set attribute="actions">
            <!-- New button added -->
            <lightning:button variant="brand" label="New Product" onclick="{!c.newContact}" />
            <!-- Delete button added -->
            <lightning:button variant="destructive" label="Delete" onclick="{!c.deleteContacts}" />
        </aura:set>
    </lightning:card>
	
</aura:component>

Controller
({
    Search: function(component, event, helper) {
        var searchField = component.find('searchField');
        var isValueMissing = searchField.get('v.validity').valueMissing;
        if(isValueMissing) {
            searchField.showHelpMessageIfInvalid();
            searchField.focus();
        }else{
            helper.SearchHelper(component, event);
        }
    },
    edit: function(component, event, helper){
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": event.target.id
       });
       editRecordEvent.fire();
    }
})

Helper
({
    SearchHelper: function(component, event) {
        // show spinner message
         component.find("Id_spinner").set("v.class" , 'slds-show');
        var action = component.get("c.fetchProduct2");
        action.setParams({
            'searchKeyWord': component.get("v.searchKeyword")
        });
        action.setCallback(this, function(response) {
           // hide spinner when response coming from server 
            component.find("Id_spinner").set("v.class" , 'slds-hide');
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                
                // if storeResponse size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                } else {
                    component.set("v.Message", false);
                }
                
                // set numberOfRecord attribute value with length of return value from server
                component.set("v.TotalNumberOfRecord", storeResponse.length);
                
                // set searchResult list with return value from server.
                component.set("v.searchResult", storeResponse); 
                
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
})

​​​​​​​​​​​​​​
 
This is the Error I get when I try to create a new project "HelloWorldLightningWebComponent" in Visual Studio Code

Starting SFDX: Create Project
14:33:27.962 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\msoundhariya\Desktop\Salesforce --template standard
ERROR running force:project:create:  Command failed with exit code 1: npm root -g --prefix c:\Users\msoundhariya\Desktop\Salesforce\.yo-repository --loglevel error
'npm' is not recognized as an internal or external command,
operable program or batch file.
14:33:29.121 sfdx force:project:create --projectname HelloWorldLightningWebComponent --outputdir c:\Users\msoundhariya\Desktop\Salesforce --template standard
 ended with exit code 1

Could anyone help to resolve this ?!
Thanks in Advance
The scenario is,
I need to send email alerts to Sales Director in the org [ in this case, it is my mail id] whenever opportunity stage update takes place and
In Approval process, mail has to be sent requesting approval.

For email alert on stage updates, I used workflow.
My workflow and Approval Process were working properly but suddenly I'm not getting email today??

I donno why suddenly it is not working?

Could anyone  help to figure this out..

Thanks in advance
I tried creating new opportunity, but it is showin me this errorUser-added imageNow, what should I do to create a new opportunity?

Thanks in Advance!!
The scenario is:

I need to send CEO Closed WON Report in Email every Week.

I created the report and when I subscribed it and tried sending report mail to me[myself and not other user], I'm getting this error.
I'm using Developer Edition.

User-added imageI'm not able to figure out how to resolve this..

Thanks in Advance!