• Santosh Kumar 348
  • SMARTIE
  • 630 Points
  • Member since 2016

  • Chatter
    Feed
  • 21
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 73
    Replies
Hello Folks,

I can't post record from workbench. 
Recieving below error message:
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName]: [LastName] Class.ReferalProgram.createlead: line 35, column 1

Appreaciate any help can provide.
@RestResource(urlMapping='/referrallead/*')
global with sharing class ReferalProgram {
   
    @HttpGet
    global static lead getLeadById() {
        //  global static opportunity getOpportunityById() {
        RestRequest request = RestContext.request;
        String leadId = request.requestURI.substring(request.requestURI.lastIndexOf('/')+1);
        
        lead result =  [SELECT lastname,firstname,email,Phone,status FROM lead WHERE Id = :leadId]; 
        return result;
    }
    
    @HttpPost
    global static ID createlead(String firstname, String lastname,String email, String phone, String company, String leadsource, String origin, String reffname, String reflname,String rectype) {
        
        lead thislead = new lead();
        List<Lead> leadlist = [select id,lastname,email from lead where email =: email];
        contact thiscontact = new contact();
        List<Contact> conList = [select id,name,email from Contact where email =: email];
        if(leadlist.size() >0 || conList.size() >0){
            thislead.Email.addError('Email already exists');
        }
        else
        thislead.Lastname = lastname;
        thislead.Firstname = firstname;
        thislead.Email = email;
        thislead.Company = company;
        thislead.phone = phone;
        thislead.leadsource = leadsource;
        thislead.origin__c = origin;
        thislead.Referrer_First_Name__c = reffname;
        thislead.Referrer_Last_Name__c = reflname;
        thislead.RecordTypeId = '012D00000007Q8D';
        insert thislead;
        return thislead.Id;
    }

    @HttpPatch
    global static ID updateleadFields() {
        RestRequest request = RestContext.request;
        String leadId = request.requestURI.substring(
            request.requestURI.lastIndexOf('/')+1);
        lead thislead = [SELECT Id FROM lead WHERE Id = :leadId];
        // Deserialize the JSON string into name-value pairs
        Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
        // Iterate through each parameter field and value
        for(String fieldName : params.keySet()) {
            // Set the field and value on the Lead sObject
            thislead.put(fieldName, params.get(fieldName));
        }
        update thislead;
        return thislead.Id;
    }    
}

 
The developer console on our partial copy instance doesn't seem to load. I am able to login into Salesforce and navigate through the screens. Its just the developer console, that's hanging. Any help to get around this, will be much appreciated.

User-added image
How to delete a target property from config elements from lwc.

for exx:
 <targetConfigs>
        <targetConfig targets="lightningCommunity__Default">
            <property name="recordId" type="String" label="Record ID" default="{!recordId}"  description="The value should be {!recordId}."/>
         <property name="objectApiName" type="String" label="Object Name" description="Automatically bind the page's object name to the component variable"
            default="{!objectApiName}" />
        </targetConfig>
    </targetConfigs>

i want to delete property objectApiName but when i remove code or delete from community page and publish that then also it return me errot that i can delete a config property,
I am in the process of developing an apex:form that will save two records: Recipient__c and Scholarship_Award__c. 

I need to create a custom controller to save new records for both objects on the same VF page. 
The trouble is the Recipient__c record will need to be saved first following the insertion of Scholarship_Award__c because it references Recipient__c as the parent in a master-detail relationship. 

Ideally, the end-user will input the fields of recipient__c, and scholarship_award__c and two records will be saved: a new recipient, and a new scholarship with that recipient as the parent. 

How can I go about developing this?
Hello,
I am having an issue where I am adding a quickaction to create a child record but the record type selector is not popping up.  The Action is a lightning component.  profile has access to record type.  Was working before I added componet.
Thanks,
Hi,

On my case record in community, I want to prevent the user from updating the case by editing the Status field. The user should be able to close the case with the click of a custom button

Appreciate if anyone can provide their ideas
 
I am overriding a new button on a custom object with an  aura component(LWC wrapped inside Aura).  How do I get the record Type  that the user has selected and pass it to the LWC?  The reason I need this is that the picklist values are based on the record type.
 
Thanks
P
picklist_example cmp
<aura:component >
    <aura:attribute name="selected" type="string" default="1"/>
    <lightning:select name="select1" label="How many tickets" value="{!v.selected}"  onchange="{!c.show}">
        <option value="">choose one..</option>
        <option value="1">one</option>
        <option value="2">two</option>
        <option value="3">three</option>
        
    </lightning:select>
    <br/><br/>
    
    <aura:attribute name="options" type="list" default="[{'label':'java','value':'ocjp'}
                                                        {'label':'sfdc','value':'admin'}
                                                        {'label':'aws','value':'aws01'}]"/>
    <aura:attribute name="value" type="list" default="option1"/>
    
           <lightning:checkboxGroup name="Checkbox Group"
                                 label="certifications"
                                 options="{!v.options}"
                                 value="{!v.value}"
                                 onchange="{!c.handleChange}"/>
    
</aura:component>

controller
({
    show : function(component, event, helper) {
        var result=event.getParam('value');
        alert(result);
        
    },
    handleChange: function (component, event) {
        alert(event.getParam('value'));
    }
})
Application
<aura:application extends="force.slds" >
    <c:picklist_example/>
    
</aura:application>
Hi ,

below code getting Error State while saving the record so i couldn't navigate to recently created record page.
 
getSave : function (component, event, helper) {
        alert('Current Record Id |' + component.get("v.recordId"));
        var action = component.get("c.GD_newQuoteVersion");
        var toastEvent = $A.get("e.force:showToast");
        action.setParams({
            //"quote":component.get("v.quote"),
            quoteId: component.get("v.recordId")
        });
        
        action.setCallback(this,function(result){
            var state = result.getState();
            alert('state ' + state);
            /*if (state == "SUCCESS") {
                var res = result.getReturnValue();
                alert('INside of success ' + res);
                component.set("v.returnId",res);
            }*/
            var newQtId = result.getReturnValue();
            console.log('Return Value is:' + JSON.stringify(result.getReturnValue()));
            alert('New Quote Id - ' + JSON.stringify(result.getReturnValue()));
            //component.set("v.returnId",data.getReturnValue());
            /*Toast Event*/
            toastEvent.setParams({
                title: "Success!",
                message: "Quote is created successfully!",
                type: "success"
            });
            toastEvent.fire();
            /*Navigation*/
            var recId = component.get("v.recordId");
            var sObectEvent = $A.get("e.force:navigateToSObject");
            sObectEvent .setParams({
                "recordId": recId,
                "slideDevName": "detail"
            });
            sObectEvent.fire();
        });
        $A.enqueueAction(action);  
    }

Can anyone please tell me where i did mistake ? 

Hearty thanks in advance.

Regards,
Soundar.
I am quite new to Force.com development, and I am struggling with an issue that I thought would be quite simple.  I have a custom VisualForce page, and I want the help text bubble icon and text to be displayed on my page, but I cannot figure out how to do that. I have read the posts on this forum for that same question and have implemented what I think is the correct approach, but it still shows nothing.  My VF code is like this:

<apex:pageBlockSectionItem HelpText="{!$ObjectType.BNTE_Build_Note__c.Fields.Work_Order_ID__c.InlineHelpText}"> 
                    <apex:outputLabel value="{!$ObjectType.BNTE_Build_Note__c.fields.Work_Order_ID__c.label}"/>
                    <apex:inputField value="{!BNTE_Build_Note__c.Work_Order_Id__c}"/> 
                 </apex:pageBlockSectionItem>

My page is set to ShowHeader = "true".

Could anybody suggest what I could try to get this to work?
Hello,

I have one field that is called "TimetoAssignSLA__c" which consists of the following formula:

IF(BMCServiceDesk__StatusChangeDate__c - BMCServiceDesk__openDateTime__c > 0 ,TEXT( FLOOR( BMCServiceDesk__StatusChangeDate__c - BMCServiceDesk__openDateTime__c ) ) & " days "& TEXT( FLOOR( MOD( (BMCServiceDesk__StatusChangeDate__c - BMCServiceDesk__openDateTime__c ) * 24, 24 ) ) ) & " hours "
& TEXT( ROUND( MOD( (BMCServiceDesk__StatusChangeDate__c - BMCServiceDesk__openDateTime__c ) * 24 * 60, 60 ), 0) ) & " minutes","")

That works exactly as I need it to and now I need to create a new field called "SLAMet" that determines if the result of "
TimetoAssignSLA__c" column is >30 minutes. If so, I want the results to say "MISSED". If <30 minutes, I want the results to say "MET". 
User-added image

Would someone be so kind to help me with the formula for the SLA Met? Please note, I will need the field type as well to ensure I set the fornula up properly. Also, is there a way if it's MISSED to make the text RED and if it's MET to make the text GREEN? If so, would you please include that in the formula as well?

Formulas aren't my strong suit and any help would be most appreciated. 

Thanks,
Sheree
I have a visualforce page located on the case object that shows a table with assets that are related to that case. From the asset table you can update the asset serial number, click the custom save button and the asset serial number updates and saves. The issue I am running into is that I added a checkbox to the asset table from the related case. When the checkbox is checked in the asset table and the save button is clicked the checkbox field on the case does not update or save. 

Here is my visualforce page code.
<apex:page standardController="Case" extensions="pullEquipmentUpdateAssetClass">     

    <p></p>
    
<!--List of Assets. Can update serial number of the asset from this table-->
    
    <apex:pageblock id="Assets"> 

         <br/> 
        
			<apex:form >
                
                <apex:pageBlockTable value="{!Assets}" var="asset">
                
                	<apex:column value="{!asset.Product_Code_Display__c}"/>
                
                	<apex:column value="{!asset.Product_Description_Display__c}"/> 
                    
                    <apex:column value="{!asset.Delivery_Address__c}"/>
                
					<apex:column value="{!asset.Serial_Number_Procurement__c}"/>
					
                    <apex:column headerValue="Serial Number"><apex:inputText value="{!asset.Serial_Number_Procurement__c}" required="true" /></apex:column>
					
                    <!-- this checkbox can be checked, but when the save button is clicked the checkbox field on the case does not update -->
                    <apex:column headerValue="Equipment has been pulled"><apex:inputCheckbox value="{!asset.Child_Fulfillment_Ticket__r.Equipment_Has_Been_Pulled__c}"/></apex:column>
                
                </apex:pageBlockTable>
               
                <apex:commandButton value="Save" action="{!saveSerialIdNumber}"/>
        
        </apex:form>
       
    </apex:pageblock>
    
</apex:page>
And here is my apex class:
public class pullEquipmentUpdateAssetClass {


    public List<Asset> Assets{get;set;}
    
    public Case Cases {get;set;} 

    public Case c {get;set;} 
    
    //Constructor 

     public pullEquipmentUpdateAssetClass(ApexPages.StandardController controller) { 

        c = (Case)controller.getRecord();      

        Cases = [SELECT id, FROM Case WHERE id=: c.id LIMIT 1]; 

        Assets = [SELECT id,Child_Fulfillment_Ticket__r.Equipment_Has_Been_Pulled__c,Serial_Number_Procurement__c,Name,Delivery_Address__c,Product_Code_Display__c,Product_Description_Display__c FROM Asset WHERE Serialized__c = true AND Child_Fulfillment_Ticket__c = :Cases.id]; 
     
     } 
  
    //save button for serial number
    
    public PageReference saveSerialIdNumber(){
        update Assets;
        Assets = [SELECT id,Child_Fulfillment_Ticket__r.Equipment_Has_Been_Pulled__c,Serial_Number_Procurement__c,Name,Delivery_Address__c,Product_Code_Display__c,Product_Description_Display__c FROM Asset WHERE Serialized__c = true AND Child_Fulfillment_Ticket__c = :Cases.id]; 
return ApexPages.currentPage();
    }
}

I am still fairly new to apex, so I am not super familiar with it 
A developer creates a customer controller and custom Visualforce page by using the following code block:
public class myController { public String myString;
public String getMyString() { return 'getMyString';
}
public String getStringMethod1() { return myString;
}
public String getStringMethod2() { if (myString == null)
myString = 'Method2'; return myString;
}
}

<apex:page controller="myController">

{!myString}, {!StringMethod1}, {!StringMethod2}, {!myString}

</apex:page>


What does the user see when accessing the custom page?

a.    getMysString, , Method2, getMyString
b.    , , Method2, getMyString
c.    , , Method2,
d.    getMyString, , ,
 
public class sampleCons {
    
    public string selectedValue {get;set;}
    public boolean isDisabled{set;get;}
    public sampleCons(ApexPages.StandardController controller){
        isDisabled=true;
    }
    public PageReference test() {
        if(selectedValue == 'True'){
        // perfom your logic here
        system.debug('====>'+selectedValue);
            isDisabled=true;
        } else if (selectedValue == 'False'){
            system.debug('====>'+selectedValue);
              isDisabled=false;
        // perform your logic here
        }
        return null;
    }
                
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('True','True')); 
        options.add(new SelectOption('False','False'));
        system.debug('====>'+options);
        return options; 
    }   
}
 
<apex:page standardController="Account" extensions="sampleCons">
    <apex:form id="myForm">
        <apex:pageMessages />
        <apex:selectRadio value="{!selectedValue}">
            <apex:selectOptions value="{!items}">
           
            </apex:selectOptions>
            </apex:selectRadio><p/>
        <apex:pageBlock title="Edit Contact" rendered="{!isDisabled}">
            <apex:pageBlockSection columns="1">
        <apex:inputField value="{!account.name}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
     </apex:form>
 </apex:page>

User-added image
I  am new to VF code, I have tried above code but it is not working for me. If I select true radio button then account name should be display and if I select false then it should be disabled
I am new to Apex and working on Leave Management App. Contact is Parent to LeaveEntry Object having Master-detail relationship on Name field.
( On contact Object while creating a record, I have First Name and LastName but on LeaveEntry Object while creating record I will select Employee full name which will populate from Contact ) 

I need clarification on 2 issues where I see errors (made their font bold)
1. Why am I getting Null value when I want to retrieve Name at System.debug
2. How can I pull Name value from contact to LeaveEntry?

@isTest
public class OnLeaveApprovalTest {
 
@isTest
public static void CreateContactRecord(){
Contact emp = new Contact ();

emp.FirstName = 'Jon';
emp.LastName = 'Snow';
emp.Emp_ID__c = 'Sp-34324';
insert emp;
system.debug('Full Name of emp is : ' + emp.Name);  // plz clarify
system.debug(emp);
 
//Enter record details on Leaves Object
Leaves__c leaveReq = new Leaves__c();
Emp Name = emp.FirstName + ' ' + emp.LastName;  //Plz Clarify
leaveReq.Request_Start_Date__c = date.newInstance(2020,06,10);
leaveReq.Request_End_Date__c = date.newInstance(2020,06,15);
Insert leaveReq;
  
}
}
Hello,
I am trying to do deepclone by below method.
i want to clone opportunity with related list
currentOpp = (Opportunity)stdController.getRecord(); 
Opportunity oppClone = currentOpp.clone(false, true);

but when i do system debug for oppClone, it only contains ID

and i have below error
Error:
insert failed. First exception on row 0 with id 0060Q00000D3AnjQAF; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Hello Trailblazers,

I'm trying to design a VFP with TWO apex tabs with each tab having a table with list of records within along with some custom "search" logic. Tab 1 will load the data by default on initial page load but I want tab 2 data to be loaded only when clicked(as a best practice). i also have a custom button within each tab which will just get the specific records onto the table. I'm really having hard time in figuring out how to achieve this as i tried to use the actionfunction ontabenter which didn't work. Please shed some light on what i might be doing wrong or share any examples specific to my use case.

VFP:
<apex:page controller="MarginTrackerController" sidebar="false">
    <apex:form >
        <apex:tabPanel title="Margin Tracker" id="tabpanelId" tabClass="activeTab" inactiveTabClass="inactiveTab" value="{!varTabId}">
            <apex:tab label="Summary" name="Summary" ontabenter="onClickSummaryTab();" switchType="ajax" id="Summary">

            </apex:tab>
            
            <apex:tab label="Margin" name="Margin" ontabenter="onClickMarginTab();" switchType="ajax" id="Margin">
            <div style="width:800px;float:left;">
            <!-- this is the filter used to SearchAction-->
            <apex:selectList multiselect="false" size="1" value="{!selectedTimeframe}">
                <apex:selectOptions value="{!timeframeList}"></apex:selectOptions>
            </apex:selectList>
            <apex:commandButton value="Go" action="{!searchAction}" status="status" rerender="formId,oppsPanel">
            </apex:commandButton>
            </div>
                <p><div class="oppstbldiv">
                <table class="oppstbl" id="myOppsTable">
                <thead>
                    <tr>
                        <th colspan="1">Opportunity</th>
                        <th colspan="1"> Type</th>
                        <th colspan="1"> Start</th>
                        <th colspan="1"> End</th>
                        <th colspan="1">Net Budget</th>
                        <th colspan="1">Sold Margin ($)</th>
                        <th colspan="1">Sold Margin (%)</th>
                        <th colspan="1">Booking Margin ($)</th>
                        <th colspan="1">Booking Margin (%)</th>
                        <th colspan="1">Revised Margin ($)</th>
                        <th colspan="1">Revised Margin (%)</th>
                    </tr>
                </thead>
                <tbody>
                    <apex:repeat value="{!oppList}" var="opp">
                        <tr>
                            <td style="text-align:left">{!opp.Name}</td>
                            <td>{!opp.Market__c}</td>
                            <td>
                                <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
                                    <apex:param value="{!opp.Start_Date__c}" /> 
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
                                    <apex:param value="{!opp.End_Date__c}" /> 
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, currency}">
                                    <apex:param value="{!opp.Net_Budget__c}" />
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, currency}">
                                    <apex:param value="{!opp.Sold_Margin__c}" />
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Sold_Margin_Percentage__c))}">
                                    <apex:param value="{!opp.Sold_Margin_Percentage__c}"/>
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, currency}">
                                    <apex:param value="{!opp.Booked_Margin__c}" />
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Booked_Margin_Percentage__c))}">
                                    <apex:param value="{!opp.Booked_Margin_Percentage__c}"/>
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, currency}">
                                    <apex:param value="{!opp.Revised_Margin__c}" />
                                </apex:outputText>
                            </td>
                            <td>
                                <apex:outputText value="{0, number, ##.##}%" rendered="{!NOT(ISNULL(opp.Revised_Margin_Percentage__c))}">
                                    <apex:param value="{!opp.Revised_Margin_Percentage__c}"/>
                                </apex:outputText>
                            </td>
                        </tr>
                    </apex:repeat>
                </tbody>
            </table>
            </div></p>
            </apex:tab>
            <apex:actionFunction action="{!SummaryTab}" name="onClickSummaryTab"/>
            <apex:actionFunction action="{!MarginTab}" name="onClickMarginTab"/>
        </apex:tabPanel>
    </apex:form>
</apex:page>

Controller:
public class MarginTrackerController {
    public List<Opportunity> oppList{get; set;}
    public Opportunity opp{get;set;}
    public List<SelectOption> timeframeList{get;set;}
    public String selectedTimeframe { get; set; }
    public String varTabId { get; set; }
    public MarginTrackerController(){
    }
    public pageReference SummaryTab(){
        varTabId = 'Summary';
        /*some logic to fetch records*/
        return null;
    }
    public pageReference MarginTab(){
        varTabId = 'Margin';
        opp = new Opportunity();
        timeframeList = new List<SelectOption>();
        timeframeList.add(new SelectOption('', '--None--'));
        selectedTimeframe = '';
        oppList = new List<Opportunity>();
        oppList = [SELECT Id, Name,Market__c, Start_Date__c, End_Date__c, Net_Budget__c, Sold_Margin__c, Sold_Margin_Percentage__c, Booked_Margin__c, Booked_Margin_Percentage__c, Revised_Margin__c, Revised_Margin_Percentage__c FROM Opportunity ORDER BY createdDate DESC LIMIT 100];
        return null;
    }   
    public void searchAction(){
        timeframeList.add(new SelectOption('', '--None--'));
        timeframeList.add(new SelectOption('Q1', 'Q1'));
        timeframeList.add(new SelectOption('Q2', 'Q2'));
        timeframeList.add(new SelectOption('Q3', 'Q3'));
        timeframeList.add(new SelectOption('Q4', 'Q4'));
        timeframeList.add(new SelectOption('Date', 'Date'));
        /*fetch the filtered records here*/
    } 
}

​​​​​​​Thanks in advance!
 
Hi Team,

How can we add Custom object Tab In Other Custom Object Edit Layout. We have tried in all aspects but none of dem have options. Is there any way to add one more Tab under the running Custom Object layout. 
Please find the Screen Shot to understand and help us.
Need To add one more Custom Object Tab
 
Hi , i have created a Button on Account object and Now i need the Apex controller code and visualforce page code Which will create a Contact when the user clicks the button. Please provide the code

Hello Salesforce Ohana,
Opportunity is connected with Custom Object A and Custom B.
Custom Object A and Custom Object B are only related by Opportunity (Lookup).

There is one more Custom object C.
Custom Object C is only connected to Custom object B not directly connected with Opportunity or Custom object A.

What I am trying to achieve to is When Custom Object c records are created then one of its fields I need to pass to Custom object A record.

Suppose 3 Custom object C records created so there will be already Custom object A 3 records available where I need to pass value from Custom object C.

It doesn't matter Custom Object C 1st number record data gets attached to Custom object A 3rd number but opportunity needs to be the same as values are unique.

 

Any suggestions or guidance will be helpful.

Thanks in advance
User-added image

I want complete Apex trigger on any object having before insert, after insert , before update, after update, before delete and after delete logic example and show its execution.How can i did that help me.
There is a current trigger for Property Object for new records created in Salesforce that will check the address in Zillow (API)  and then update the field Parcel ID when the address is located. However, when I use dataloader for new records bulk upload, this trigger isn't firing. I still have to manually update each Property and refresh for the trigger to fire. Can you please help me with how I can fix this to work on bulk uploads?

Here is the PropertyHandler trigger that I can see in Dev Console:

public class PropertyDetailsHandler {
    public static Integer counter;
    static {
        counter = 1;
    }
    
    public static void checkAddress(List<Property_Details__c> newList, List<Property_Details__c> oldList){
        Set<Id> udpatedList = new Set<Id>();
        for(Integer i=0; i< newList.size(); i++){
            if(newList[i].Street_Address__c != oldList[i].Street_Address__c 
               ||
               newList[i].Unit_Number__c != oldList[i].Unit_Number__c 
               ||
               newList[i].State__c != oldList[i].State__c 
               ||
               newList[i].City__c != oldList[i].City__c
               ||
               newList[i].Postal_Code__c != oldList[i].Postal_Code__c){
                   udpatedList.add(newList[i].Id);
                   updateName(newList[i]);
                       
               }
        }
        if(udpatedList.size() > 0){
            
            if(System.Label.Is_Zillow_Active == '1' || Test.isRunningTest()){
                ZillowController.updateFromZillow(udpatedList);
            }
            if(System.Label.Is_Zillow_Active == '0'){
                BridgeController.updateFromBridge(udpatedList);
            }
        }
    }
    
    public static void updateName(Property_Details__c prop){
        prop.Name = '';
        if(prop.Street_Address__c != null &&prop.Street_Address__c != ''){
            prop.Name =prop.Street_Address__c;
        }
        if(prop.Unit_Number__c  != null &&prop.Unit_Number__c != ''){
            if(prop.Name != ''){
                prop.Name += ', #' +prop.Unit_Number__c; 
            }
        }
        
        if(prop.City__c  != null && prop.City__c != ''){
            if(prop.Name != ''){
                prop.Name += ', ' + prop.City__c; 
            }
        }
        
        if(prop.State__c  != null && prop.State__c != ''){
            if(prop.Name != ''){
                prop.Name += ', ' + prop.State__c; 
            }
        }
        
        if(prop.Postal_Code__c  != null && prop.Postal_Code__c != ''){
            if(prop.Name != ''){
                prop.Name += ' ' + prop.Postal_Code__c; 
            }
        }
        if(prop.Name != '' && prop.Name.length() >80){
            prop.Name = prop.Name.left(80);
        }
    }
}
 
Can someone help with Test class for below.

Thanks in Advance
 
@RestResource(urlMapping='/referrallead/*')
global with sharing class ReferalProgram {
   
    @HttpGet
    global static lead getLeadById() {
        //  global static opportunity getOpportunityById() {
        RestRequest request = RestContext.request;
        String leadId = request.requestURI.substring(request.requestURI.lastIndexOf('/')+1);
        
        lead result =  [SELECT lastname,firstname,email,Phone,status FROM lead WHERE Id = :leadId]; 
        return result;
    }
    
    @HttpPost
    global static ID createlead(String firstname, String lastname,String email, String phone, String company, String leadsource, String origin, String reffname, String reflname,String rectype) {
        
        lead thislead = new lead();
        List<Lead> leadlist = [select id,lastname,email from lead where email =: email];
        contact thiscontact = new contact();
        List<Contact> conList = [select id,name,email from Contact where email =: email];
        if(leadlist.size() >0 || conList.size() >0){
            thislead.Email.addError('Email already exists');
        }
        else
        thislead.Lastname = lastname;
        thislead.Firstname = firstname;
        thislead.Email = email;
        thislead.Company = company;
        thislead.phone = phone;
        thislead.leadsource = leadsource;
        thislead.origin__c = origin;
        thislead.Referrer_First_Name__c = reffname;
        thislead.Referrer_Last_Name__c = reflname;
        thislead.RecordTypeId = '012D00000007Q8D';
        insert thislead;
        return thislead.Id;
    }

    @HttpPatch
    global static ID updateleadFields() {
        RestRequest request = RestContext.request;
        String leadId = request.requestURI.substring(
            request.requestURI.lastIndexOf('/')+1);
        lead thislead = [SELECT Id FROM lead WHERE Id = :leadId];
        // Deserialize the JSON string into name-value pairs
        Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
        // Iterate through each parameter field and value
        for(String fieldName : params.keySet()) {
            // Set the field and value on the Lead sObject
            thislead.put(fieldName, params.get(fieldName));
        }
        update thislead;
        return thislead.Id;
    }    
}

 
Hello Folks,

I can't post record from workbench. 
Recieving below error message:
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName]: [LastName] Class.ReferalProgram.createlead: line 35, column 1

Appreaciate any help can provide.
@RestResource(urlMapping='/referrallead/*')
global with sharing class ReferalProgram {
   
    @HttpGet
    global static lead getLeadById() {
        //  global static opportunity getOpportunityById() {
        RestRequest request = RestContext.request;
        String leadId = request.requestURI.substring(request.requestURI.lastIndexOf('/')+1);
        
        lead result =  [SELECT lastname,firstname,email,Phone,status FROM lead WHERE Id = :leadId]; 
        return result;
    }
    
    @HttpPost
    global static ID createlead(String firstname, String lastname,String email, String phone, String company, String leadsource, String origin, String reffname, String reflname,String rectype) {
        
        lead thislead = new lead();
        List<Lead> leadlist = [select id,lastname,email from lead where email =: email];
        contact thiscontact = new contact();
        List<Contact> conList = [select id,name,email from Contact where email =: email];
        if(leadlist.size() >0 || conList.size() >0){
            thislead.Email.addError('Email already exists');
        }
        else
        thislead.Lastname = lastname;
        thislead.Firstname = firstname;
        thislead.Email = email;
        thislead.Company = company;
        thislead.phone = phone;
        thislead.leadsource = leadsource;
        thislead.origin__c = origin;
        thislead.Referrer_First_Name__c = reffname;
        thislead.Referrer_Last_Name__c = reflname;
        thislead.RecordTypeId = '012D00000007Q8D';
        insert thislead;
        return thislead.Id;
    }

    @HttpPatch
    global static ID updateleadFields() {
        RestRequest request = RestContext.request;
        String leadId = request.requestURI.substring(
            request.requestURI.lastIndexOf('/')+1);
        lead thislead = [SELECT Id FROM lead WHERE Id = :leadId];
        // Deserialize the JSON string into name-value pairs
        Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(request.requestbody.tostring());
        // Iterate through each parameter field and value
        for(String fieldName : params.keySet()) {
            // Set the field and value on the Lead sObject
            thislead.put(fieldName, params.get(fieldName));
        }
        update thislead;
        return thislead.Id;
    }    
}

 
The developer console on our partial copy instance doesn't seem to load. I am able to login into Salesforce and navigate through the screens. Its just the developer console, that's hanging. Any help to get around this, will be much appreciated.

User-added image
public class OrignContrl {

  public decimal xvalue{get;set;}
  
   public decimal yvalue{get;set;}
   
   public string Totalcost{get;set;}
   
     public OrignContrl(){
      Totalcost ='Testing';
      }


    public void setvalues(){
    xvalue =48.05;
    yvalue =50.06;
   
     }
    
}

visualForce page:

 
<apex:page controller="OrignContrl" >
 <apex:form >
 <apex:commandButton value="Display in selected format" Action="{!setvalues}" />
 <apex:outputLabel >{!Totalcost}</apex:outputLabel>
 </apex:form>
</apex:page>

onclick on the button the values assigned to the particular outputlabel and display

thanks and regards
soumya reddy
Hi,

I am getting owner id in the data table for lightning component, when using

{label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            
            {label: 'Created By', fieldName: 'Owner__c'},

and no value when I try to use :

{label: 'Account Name', fieldName: 'linkName', type: 'url', 
            typeAttributes: {label: { fieldName: 'Account_Name__c' }, target: '_blank'}},
            
            {label: 'Created By', fieldName: 'Owner__r.Name'},

on lightning component screen.

Also , the records that get created on save are displayed in tabular form, but gets saved randomly in table ordrer, i want to arrange them in order of creation time, with the last created record to be on the top of table
How to delete a target property from config elements from lwc.

for exx:
 <targetConfigs>
        <targetConfig targets="lightningCommunity__Default">
            <property name="recordId" type="String" label="Record ID" default="{!recordId}"  description="The value should be {!recordId}."/>
         <property name="objectApiName" type="String" label="Object Name" description="Automatically bind the page's object name to the component variable"
            default="{!objectApiName}" />
        </targetConfig>
    </targetConfigs>

i want to delete property objectApiName but when i remove code or delete from community page and publish that then also it return me errot that i can delete a config property,
I am in the process of developing an apex:form that will save two records: Recipient__c and Scholarship_Award__c. 

I need to create a custom controller to save new records for both objects on the same VF page. 
The trouble is the Recipient__c record will need to be saved first following the insertion of Scholarship_Award__c because it references Recipient__c as the parent in a master-detail relationship. 

Ideally, the end-user will input the fields of recipient__c, and scholarship_award__c and two records will be saved: a new recipient, and a new scholarship with that recipient as the parent. 

How can I go about developing this?
Hello,
I am having an issue where I am adding a quickaction to create a child record but the record type selector is not popping up.  The Action is a lightning component.  profile has access to record type.  Was working before I added componet.
Thanks,
Hi

I have written a apex code to call the API (Mulesoft), In order to record the API response I have created a Log table. When a record is created in the Log table, I need to update the record status of the Object (on which the API call was made) to depending on whether the API call was success or failure. I have written a Flow to achieve this. I am passing the recordId of to the flow and to the APEX code. The issue I am facing while updating the record using the recordId within a Update Record instance, I am not aware which Object the record belongs. As a result I have to expand my flow to include an Update Record for each Object for which I am expecting the API respose.

Is it possible to make the "Object" a variable within the "Update Record" Element in the Flow ?? OR Identify the Object Name from the recordId within the Flow.