• Deepali Kulshrestha
  • PRO
  • 4196 Points
  • Member since 2016
  • Salesforce Developer
  • Cloud Analogy


  • Chatter
    Feed
  • 139
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 1225
    Replies
My company's org has about five triggers more than one existing (after insert, after edit).  I am about to create an (after insert) trigger.  Suggestions as to how I would consolidate or should I create my trigger and add to the pile.  If I should consolidate, how would that look?
Hello, 
I am trying to display some information but everytime I have this following message error :
SObject row was retrieved via SOQL without querying the requested field: Contact.Client_a_risque__c

Here below is my code : 

<!--*********************************************************************************
Class Name      : CCF_CustomContactSearch
Description     : This page will be open by InIn on an Agent's browser, once a Case is 
                  assigned to the Agent. 
                  When loaded, the page will contain a list of Contacts 
                  possibly matching to a value (svalue) contained in the URL as a parameter
                  The Agent also has the option to search for a specific contact, using the
                  input field beside "Search Contact" button. The value provided in the input 
                  field will be searched in ALL fields in the Contact Object
                  For every listed Contact, the Agent has the option lo link it to the Case,
                  using "Link to Case" button
Created By      : Mihai JURIAN
Created Date    : 30-Jan-17
Modification Log:
================================================================================== 
Developer                   Date                   Description
==================================================================================        
Mihai Jurian            30-Jan-17                   Initial Version
*********************************************************************************-->
<apex:page controller="CCF_searchContactController" docType="html-5.0" action="{!search_onLoad}" title="{!$Label.InIn_Recherche_de_contact}">

    <apex:includeScript value="/support/console/28.0/integration.js"/>
    <script type="text/javascript">
        function openCaseDetails() {
            sforce.console.openPrimaryTab(undefined, '/{!caseId}', true, '{!caseNumber}');
            closeTab();
        }

        // The callback function that closeTab will call once it has the ID for its tab
        var callCloseTab = function callCloseTab(result) {
            sforce.console.closeTab(result.id);
        }
    
        function closeTab() {
            sforce.console.getEnclosingPrimaryTabId(callCloseTab);
        }
    
        var pageLoad = window.onload;
        window.onload = function() 
        {
            if (pageLoad) 
            {
                pageLoad();
            }
            sforce.console.setTabTitle('{!$Label.InIn_Recherche_de_contact}');
        }
    </script>
    <apex:form >
        <apex:actionFunction name="updateSortOrderBy1" action="{!updateSortOrderBy}">
            <apex:param id="updateOrderBy" name="updateOrderBy" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="search_method" action="{!search_method}" />

        
        <apex:input value="{!searchValue}" id="searchValue"/>
        <apex:commandButton value="{!$Label.InIn_Trouver_le_Contact}" onclick="search_method(); return false;" />
        <apex:outputText id="searchWarning" value="Please enter at least 2 characters before searching." rendered="{!showSearchWarning}" />
        
       
        <apex:pageBlock title="Contacts" id="block">
            <apex:inputCheckbox value="{!excludeHasFilter}"  onclick="search_method();" />
            <apex:outputText >{!$Label.CCF_CustomSearch_IncludeAllRecords}</apex:outputText>
            <br/>&nbsp;
            <apex:pageMessages />
            <!-- the Pagination/Navigation buttons -->
            <apex:pageBlockButtons rendered="{!RenderNavigation}" location="bottom"> 
                <apex:commandButton value="{!$Label.navigationFirst}" action="{!first}" disabled="{!DisablePrevious}"/>
                <apex:commandButton value="{!$Label.navigationPrevious}" action="{!previous}" disabled="{!DisablePrevious}"/>
                <apex:commandButton value="{!$Label.navigationNext}" action="{!next}" disabled="{!DisableNext}"/>
                <apex:commandButton value="{!$Label.navigationLast}" action="{!last}" disabled="{!DisableNext}"/>
            </apex:pageBlockButtons>
            <!-- the table showing the Contacts -->
            <apex:pageblockTable id="contactList" value="{!conListToShow}" var="con">
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Name.Label + IF(orderBy == 'Name', '▼', IF(orderBy == 'Name DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Name" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputLink value="/{!con.Id}" id="theLink">{!con.name}</apex:outputLink>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Birthdate.Label + IF(orderBy == 'Birthdate', '▼', IF(orderBy == 'Birthdate DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Birthdate" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Birthdate}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Phone_1__c.Label + IF(orderBy == 'Phone_1__c', '▼', IF(orderBy == 'Phone_1__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Phone_1__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Phone_1__c}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Phone_2__c.Label + IF(orderBy == 'Phone_2__c', '▼', IF(orderBy == 'Phone_2__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Phone_2__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Phone_2__c}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Phone_3__c.Label + IF(orderBy == 'Phone_3__c', '▼', IF(orderBy == 'Phone_3__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Phone_3__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Phone_3__c}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Email_1__c.Label + IF(orderBy == 'Email_1__c', '▼', IF(orderBy == 'Email_1__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Email_1__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Email_1__c}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Email_2__c.Label + IF(orderBy == 'Email_2__c', '▼', IF(orderBy == 'Email_2__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Email_2__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Email_2__c}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Agency_PIN__c.Label + IF(orderBy == 'Agency_PIN__c', '▼', IF(orderBy == 'Agency_PIN__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Agency_PIN__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Agency_PIN__c}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!'Record Type' + IF(orderBy == 'RecordType.Name', '▼', IF(orderBy == 'RecordType.Name DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="RecordType.Name" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.RecordType.Name}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Client_a_risque__c.Label + IF(orderBy == 'Client_a_risque__c', '▼', IF(orderBy == 'Client_a_risque__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Client_a_risque__c" assignTo="{!updateOrderBy}"/>
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputfield value="{!con.Client_a_risque__c}"/>
                </apex:column>
                <!-- the buttons "Link to Case" -->
                <apex:column headervalue="{!$Label.Link_to_Case}">
                    <apex:commandButton value="{!$Label.Link_to_Case}" action="{!linkContactToCase}" rerender="block" oncomplete="openCaseDetails()">
                        <apex:param name="theContactId" value="{!con.Id}" assignTo="{!contactId}"/>
                    </apex:commandButton>
                </apex:column>
            </apex:pageblockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>


THANK YOU VERY MUCH FOR YOUR HELP.
hi,
my requirement is

 After the batch is over, Teacher will mark the batch as complete. Then the course will be moved from Requested Courses to Completed Coursed for all the students of the batch. Before marking a batch as complete, the teacher can remove any student from the batch. This will not be possible after the batch is completed.
Relationship:
User-added imageim trying to access the students whose batch is completed(batch has a checkbox mark as complete or not)
trigger Batch on Batch__c (before insert,after update) {
    List<String> b= new List<String>();  
     for(Batch__c p: Trigger.new){
         b.add(p.Name);
     }
    List<Student__c> c=new List<Student__c>([select Student__r.Name from Student_Batch_Junction__c where Batch__r.Name in :b]);
    
    
}

I tried to access student in this way..it is showing error
I have Account When Record is created ,i have to COLONE THAT RECORD VALES AND  create one Child Account Child record in same Object using FIELD SETS  
i am new to salesforce getting parssing error what is wrongwith my query 

select id,name (select id, name from Contacts) from Account where Name ='test6'
I'm trying to create a class based on files, which is ContentDocument object.  I'm trying to create a map where the key is the ID of the ContentDocument and the value is a list of LinkedEntityId that are related to the key.  

I'm not sure how to do this.  I took a shot here but I don't think it's correct.  

I'm thinking that the key is correct, but I don't know how to get the values for each key.  Each key will have a few Ids for the value. 


***I'm passing a list called 'docs' from a trigger.  The list is essentially all of the docs that were passed from trigger.new


  public static void ProcessFiles(List<ContentDocument> docs){
        
Map<Id,List<ContentDocumentLink>> FilesMap = New Map<Id,List<ContentDocumentLink>>();
 
List<ContentDocumentLink> l = [SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN : docs];


 
        for(ContentDocument c : docs){
            FilesMap.put(c.Id,l);
                
        }
        
    }  



Any help would be awesome!
<apex:page controller="SignUpPage">
<apex:form >
    <apex:pageBlock title="Profile Details">
    *Required Field
 <apex:pageBlockSection >
    <apex:inputText value="{!sup.User_Name__c}" label="User Name *"/>
    <br></br>
    <apex:inputsecret value="{!sup.Type_Password__c}" label="Type Password *"/>
    <br></br>
    <apex:inputsecret value="{!sup.Retype_Password__c}" label="Retype Password *"/>
    <br></br>
    <apex:commandButton value="Create Profile" action="{!CreateProfile}"/><br></br>    
   </apex:pageBlockSection>
 </apex:pageBlock>
</apex:form>
</apex:page>
Hi all,

I am trying to write information from the opportunitylineitem to the opportunity. On the LineItem there is a field called Product which is a standard lookup field to the product object. I am trying to get that name to go from the LineItem to the Opportunity to a custom field called product. When I was trying to reference the Standard lookup product I kept getting an error message saying it wasn't a field so changed it to the description to see if i could get the description to go from the LineItem to the Opportunity. The trigger did save but it didn't work so I wanted to post my code here to see if anyone could help.

So my first question is how do I reference a standard lookup field in apex and the second is this the best way to get information from the LineItem to the opportunity?
 
trigger OpportunityProductTrigger on OpportunityLineItem (after update) {

List<Id> oppIds = new List<Id>();
String Item;

    if(trigger.isAfter) {
        for (OpportunityLineItem oli: trigger.new){
            oppIds.add(oli.opportunityID);
        }
        List<OpportunityLineItem> allOLI = [SELECT id, ProductCode FROM OpportunityLineItem WHERE OpportunityId in: oppids];
        List<Opportunity> oppsToUpdate = [SELECT id, Product__c FROM Opportunity WHERE id in: oppids];
        if(allOLI.size() > 0){
          for(OpportunityLineItem allOLI2: allOLI){
                    Item = allOLI2.ProductCode;
                }//END if(allOLI2.Number_of_Months__c > contractLengthMonths)
            } //END for(OpportunityLineItem allOLI2: allOLI)
            for(Opportunity oppUpdate: oppsToUpdate){
                oppUpdate.Product__c = Item;
            }// END for(Opportunity oppUpdate: oppsToUpdate)
 
        }

}

 
public class Search_For_User {
String keyword;
List<user>results = new List<user>();
public String getkeyword(){
return keyword;
}
public List<user> getresults(){
return results;
}
public void setkeyword(String input){
keyword = input;
}
public PageReference searchUser(){
results = (List<User>)[FIND :keyword IN NAME FIELDS RETURNING USER(FirstName, LastName, ProfileId)][0];
return null;
}
System.debug(results);
}
Can someone help me please...
Hi Everyone Anyone Help Me I want to use After Insert,After Update,After Delete in one trigger  througth  trigger Handler and 
i want to call all these events in one method from trigger in trigger handler class  

Anyone Have Example anyone do this types of scenarios when used these events so please help me
write a trigger to update opportunity currency the same as the opportunity owner currency in before insert.
How to create a static resource using apex class?
I tried this : 
 
import { LightningElement, api, wire } from "lwc"; import { getRecord } from "lightning/uiRecordApi"; import ACCOUNT_RECORDTYPE_FIELD from '@salesforce/schema/Account.RecordTypeId'; export default class Account_Redirect extends NavigationMixin(LightningElement) { @api recordId; @api objectApiName; @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNT_RECORDTYPE_FIELD] }) acc; get recordTypeId() { return this.acc.data.fields.RecordTypeId.value; } }
But i have the following error : 
"Cannot read property 'fields' of undefined" 
{
    "data": {
        "xmlns": {
            "cpcdef": "ABCD",
        },
        "search": {
            "total-result-count": "1",
            "ops:query": {
                "syntax": "CQL",
                "$": "123456"
            },
            "range": {
                "begin": "1",
                "end": "1"
            },
            "documents": [
                "produced-by": "RO",
             }]
     }
}
Hello, Everybody !
I am new to development and I need help. Maybe someone could give me apex code example and explain me how to access
Data ---> Search ---> documents ---> produced-by = "RO"

 
trigger opptyShareTrig on Opportunity (after insert) {
      List<OpportunityShare> share=new List<OpportunityShare>();
      User u=[select id from User where alias='knair'];
      for(Opportunity op:Trigger.New){
            if(op.stageName=='Closed Won'){
                        OpportunityShare os=new OpportunityShare();
                        os.OpportunityId=op.id;
                        os.UserOrGroupId=u.id;
                        os.OpportunityAccessLevel='Edit';
                        os.RowCause='Manual';
                        share.add(os);
            }
      }
    insert share;
  }


Getting Error
I am trying to build a component which would allow users to upload a .csv file and then have additional logic to handle the contents of the file. I am trying to use LWC but it needs to be associated with a record, so it is only working on record pages. I followed the examples in the documentation here: https://developer.salesforce.com/docs/component-library/bundle/lightning-file-upload/documentation

Is there a way around this to allow it to work as a component on the home page?
Hey guys , I am beginner to salesforce, My requirement is to write the Apex trigger,
-- Suppose I have 1 account Name X and It has 2 contacts, so for the same account X , the email of the Contacts should not be same , if same It should show error. Suppose 1 contact email is abc@g.com and 2 contact email is xyz @g.com , this should be accepted. if both contact has same email address then it should not be accepted.

But  if have another account Name Y and it has 2 contact, and if email of 1 of the contact is abc@g.com  which is the email of  contact of account  X then it should be accepted, 

So please suggest me the apex trigger for the above requirement.
Note- Please dont share any link for this,, if possible give me explanation with example 

Thank you
i am trying to display the time from Apex controller to Lightning component. 
is it possible to directly get Datetime.now () in the js controller and display it on the component? 



({	
	ctr : function(cmp, event, helper) {
        var temp = [];
       
        var action = cmp.get("c.getGraph");
        action.setParams({
        	"accountid": cmp.get("v.recordId")
       	});
        action.setCallback(this, function(response){
            if(response.getState() === 'SUCCESS' && response.getReturnValue()){
                temp = response.getReturnValue();
                helper.createGraph(cmp, temp);
            }
        });      
          
       $A.enqueueAction(action);
      
	},
    
    cancelAction: function(component, event, helper) {
   		$A.get("e.force:closeQuickAction").fire();
	}
})



 
Hi All,
I want to get grand total of formula field.My report is meant to give the movement of work in progress value from month to month. For the same I have created two formula fields and every thing is working fine. Now what I want is to get grand total of one of the formula field. It is a matrix report. Please help me with this.

Thanks in advance.User-added image
 
Hi,
I created a process builder recently. As it was no longer in use I deleted it from my org. Now, while making any changes in the records I am still receiving the mail with error message regarding process builder failure. 
Error element myRule_1_A1 (FlowRecordUpdate).
The flow tried to update these records: 0034100000TxUl2AAF. This error occurred: ALL_OR_NONE_OPERATION_ROLLED_BACK: Record rolled back because not all records were valid and the request was using AllOrNone header.

It would be helpful of you if you can solve my problem.
Regards,
Deepali
Hi,
I am trying to create dashboard using Sales Analytics app. It seems that lot has been changed in Winter'18 release. While creating new app I am getting following ERROR: 33 User Dataflow Instructions executed, 41 failed.Please let me know how to resolve it. Thanks 
Hi All, 
I am new to Pardot. My requirement is to send email alert to user and an additional email whenever a Prospect is created in Pardot. I want to send the same email which is generated by default to assigned user only. I tried creating engagement studio and one-to-one email but was not able to find the solution. Please help me solve my issue
Hi All,
While setting up developer console for my Enterprise edition I don't know why it is not showing up in lightning inspite of the fact that lightning is enabled for the org.​ Can anyone help me with it?​
User-added image

Regards,
Deepali
When i am trying to delete ToAddress Field data From EmailMessage Object I am Getting Error like.
Delete failed.  INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []

I tried with Query 
List<EmailMessage> lst = [Select ToAddress From EmailMessage];
Delete lst;

can any one Plz respond to above  Problem .
Thanks in advance.
Is there any way that I can get installed package version using SOQL query?
I need my "text" in this VF to align to the right but it stays to the left. Here is my code:
 
<apex:page controller = "timeStamp_controller" >
	<table style="text-align:right;">
    	   {!NOW()}   
       </table> 
</apex:page>

{!NOW()} is what I need to alighn to the right

Hi,
I have a test class that deletes custom object record  at the end of day if the value of Grand Total field is 0.

Grand Total field is a roll up field, and is calculated basis the line item value.

Here is my batch class.

global class ProductInterestDeleteBatch implements Database.Batchable<sObject>,Schedulable{
    
    global void execute(SchedulableContext sc){
        ProductInterestDeleteBatch bc = new ProductInterestDeleteBatch();
        database.executeBatch(bc);
    }
    global Database.QueryLocator start(Database.BatchableContext bc){
        return database.getQueryLocator([SELECT Id FROM Product_Interest__c WHERE Grand_Total__c=0]);
    }
    global void execute(Database.BatchableContext bc,List<Product_Interest__c> productInterestList){
        if(!productInterestList.isEmpty()){
            database.delete(productInterestList,false);
        }
    }
    global void finish(Database.BatchableContext bc){
        
    }

}



I need help in writting test class for the same.

Send total balance of Bank Account to account holder (which is a contact) on first day of every month.
Hi Guys,
Has Anybody  written a test class for the Apex class used in this trailhead below . Apex Class name is EinsteinVision_Admin:

Trailhead 
https://trailhead.salesforce.com/en/content/learn/projects/build-a-cat-rescue-app-that-recognizes-cat-breeds

Below is the Apex Class Snippet:

public class EinsteinVision_Admin {
    @AuraEnabled
    public static void createDatasetFromUrl(String zipUrl) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        service.createDatasetFromUrlAsync(zipUrl);
    }
    @AuraEnabled
    public static List<EinsteinVision_Dataset> getDatasets() {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        return datasets;
    }
    @AuraEnabled
    public static String trainDataset(Decimal datasetId) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Model model = service.trainDataset(Long.valueOf(String.valueOf(datasetId)), 'Training', 0, 0, '');
        return model.modelId;
    }
    @AuraEnabled
    public static void deleteDataset(Long datasetId) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        service.deleteDataset(datasetId);
    }
    @AuraEnabled
    public static List<EinsteinVision_Model> getModels(Long datasetId) {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Model[] models = service.getModels(datasetId);
        return models;
    }
    @AuraEnabled
    public static void getCatPrediction(Id catId, String fileName, String base64) {
        Blob fileBlob = EncodingUtil.base64Decode(base64);
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        for (EinsteinVision_Dataset dataset : datasets) {
            if (dataset.Name.equals('Einstein_Photos')) {
                EinsteinVision_Model[] models = service.getModels(dataset);
                EinsteinVision_Model model = models.get(0);
                EinsteinVision_PredictionResult result = service.predictBlob(model.modelId, fileBlob, '');
                EinsteinVision_Probability probability = result.probabilities.get(0);
                Claim claim = [SELECT Id FROM Claim WHERE Id=:catId];
                System.debug('===claim ID==='+claim);
                claim.Claim_Accident_Categories__c = probability.label;
                update claim;
                Attachment[] attsOld = [SELECT Id FROM Attachment WHERE ParentId=:catId];
                System.debug('===attachment ID==='+attsOld);
                delete attsOld;
                Attachment att = new Attachment();
                att.Body = fileBlob;
                att.ParentId = claim.Id;
                att.Name = fileName;
                insert att;
            }
        }
    }
    @AuraEnabled
    public static Claim getClaimFields(Id claimId ) {
        Claim claim1 = [SELECT Id,Claim_Accident_Categories__c,Vehicle_Speed_Predicted__c,Likely_Injuries__c,Vehicle_damage__c,Damage_Impact__c FROM Claim WHERE Id=:claimId];
        system.debug('claim1'+claim1);
        return claim1;
    }
    
    @AuraEnabled
    public static List<EinsteinVision_Label> getCatLabels() {
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService();
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        for (EinsteinVision_Dataset dataset : datasets) {
            if (dataset.Name.equals('Einstein_Photos')) {
                return dataset.labelSummary.labels;
            }
        }
        return null;
    }
    @AuraEnabled
    public static String getImageUrlFromAttachment(Id catId) {
        List<Attachment> atts = [SELECT Id FROM Attachment WHERE ParentId=:catId];
        System.debug('===id==='+atts);
        if (atts.size()>0) {
            return atts.get(0).Id;
        }
        return '';
    }
}
iam new to salesforce how to write the test class bleow  code explain any one 


trigger Conference on User__c (after insert,after Update) 
{
    //Checking the Data Inserting || updating
    if(Trigger.isInsert || Trigger.isUpdate)
    {
        // fetching newly added User__C from Conference__c 
        list<Conference__c> conference = [SELECT Id,ConferenceName__c,Location__c,StartDate__c,Detail__c,EndDate__c,(select id,Name__c, Email__c,Relationship__c from Users__r where id in:Trigger.newMap.keySet())
                                          FROM Conference__c where id in (select Relationship__c From User__c where Id =:Trigger.newMap.keySet())];
        // Checking the Condition either value is their or Not
        if(!conference.IsEmpty())
        {
            // Conference Loop For (Parent-Object) 
            for(Conference__c con : conference)
            {
                //User Loop For (Child-Object) 
                for(User__c use : con.Users__r)
                {
                    //Checking the Condition Whether Relationship is Empty or Value
                    if(use.Relationship__c != null)
                    {
                        con.Id = use.Relationship__c;
                        
                        // Step 1: Create a new Email
                        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                        // Step 2: Set list of people who should get the email
                        List<String> sendTo = new List<String>();
                        sendTo.add(use.Email__c);  
                        mail.setToAddresses(sendTo);
                        
                        // Step 3: Set who the email is sent from
                        mail.setReplyTo(use.Email__c);
                        mail.setSenderDisplayName('Export Solutions and Techonologies');
                        
                        // Step 4. Set email contents - you can use variables!
                        mail.setSubject('URGENT BUSINESS COnfernce ');
                        String body = 'Dear ' +use.Name__c  + ',<br/> ';
                        body += 'Conference Name:' +con.ConferenceName__c+',<br/>';
                        body += 'Location:' +con.Location__c+',<br/>';
                        body += 'StartDate:' +con.StartDate__c+',<br/>';
                        body += 'StartDate:' +con.EndDate__c+',<br/>';
                        body += 'Detail:' +con.Detail__c+',<br/>';
                        body += 'Your Added This Metting .<br/>';
                        mail.setHtmlBody(body);
                        
                        // Step 6: Send all emails in the master list
                        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                    }
                }
            }
        } 
    }
}
I want to send an email alert Physician Whenever a Physician-Contact Record is created. Physican-Contact object is having lookup relation ship with Physician. When I am creating a Physician-Contact Record Physician is required. An Email alert should be sent to that particular physician email which is available in Physician object.
public class DuplicatePanCheck {
    public static void duplicatePanNo(List<Consultant__c> cons){
        for(Consultant__c c: cons){
                if(c.Pan_Number__c!= null){ 
                List<Consultant__c> con = [select id,Pan_Number__c,Phone__c,Email__c from Consultant__c where Pan_Number__c =: c.Pan_Number__c];  //checking the duplicate record based on the pan number
                        if(con.size()>1){
                        for(Consultant__c cn : con){   //if duplicate records found, updating phone, email fields in the old records 
                            cn.Phone__c = c.Phone__c;
                            cn.Email__c = c.Email__c;
                        }
                    update con;
                }
            }
        }
    }
}

trigger Trigg_DuplicatePanCheck on Consultant__c (after insert) {
    DuplicatePanCheck.duplicatePanNo(Trigger.new);
}
 
hi guys, my question is 'If roll up summary is updated , apex trigger will be fire or not??

Note- please dont share any link
Hi all,

I have little bit confuse, what is the major difference between trigger and workflow? I need the explain on scenario wise , give me best example ,what kind of situation we can choose trigger instead of workflow, kindly do the needful.


Chanti
What is the difference between workflow and triggers? When to use workflow and when to use trigger ?
How can i delete a record on click of Delete button?
 User-added image

Thank you
Jagan

Hi,

I am new to salesforce.pl anyone can help me how to implement trigger for the following

        When a number is inserted, how to find that number is even/odd or prime number or armstrong or a palindrome.

Thanks in advance