• Raj V
  • ALL STAR
  • 11026 Points
  • Member since 2016

  • Chatter
    Feed
  • 361
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 3204
    Replies
Hi 
I create a char with barSeries, but female bar is too short. Any idears?
User-added image
<apex:page >
    <apex:chart data="dataArray" width="500" height="200">
        <apex:axis type="Category" fields="gender" position="left" title="Gender"/>
        <apex:axis type="Numeric" fields="amount" position="bottom" title="PeopleAmount"/>
        <apex:barSeries axis="bottom" orientation="horizontal" xField="amount" yField="gender"/>
    </apex:chart>
    <script>
    	var dataArray = new Array();
        dataArray.push({'amount':1225,'gender':'Male'});
        dataArray.push({'amount':1189,'gender':'Female'});
    </script>
</apex:page>


 
Hi, I have two objects Parent__c and Child__c in Master-Detail relationship.
There is need that create a trigger on Child__c which can automatically create parent record when child records are insert or update.
Is that possible?
My understanding is a child record cannot be inserted without parent record ID.
SELECT CaseNumber, Case_State__c, Priority, Status, Case_Sub_Status__c FROM Case WHERE Status != 'Complete' AND OwnerId=:UserInfo.getUsername()

Unknown error is coming for the above one .. I am trying to get all the open cases for the user who is running this stmt. 
  • August 17, 2018
  • Like
  • 0

I want to get all contact filed label and API names using rest call. But I didn't find any endpoint for this.

Please tell me how to get it?

so I have been trying to teach myself how to construct lightning components by putting things from trailhead and other pages to practice but im not sure what im missing to be able to see any styling or formatting i have even tried copying things straight from https://developer.salesforce.com/docs/component-library/bundle/ just to see how it should work and look. Can anyone tell me what im doing wrong or what I am missing or if it's broken how can i fix it. Without seeing it first hand and moving things around myself I will have trouble knowing what im doing.
aura page
component code
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <p>start component</p>
    <aura:attribute name='name' type='String' Default='Pearson'>    
    </aura:attribute>
    <p>>Naeem {!v.name}</p>
    <p>
        figure out what i am making
        form
        figure out what is needed for a form
        title
    </p>
    <div class="c-container">
    <lightning:card title='first card' >
        <lightning:layout horizontalAlign="space">
            <lightning:layoutItem flexibility="auto" padding="around-small">
                <h1 class="slds-text-heading_large">This is the Title</h1>
            </lightning:layoutItem>
       </lightning:layout> 
        
        <lightning:buttonMenu aura:id="menu" onselect="{! c.handleSelect }" alternativeText="Show menu">
            <lightning:menuItem value="MenuItemOne" label="Menu Item One" />
            <lightning:menuItem value="MenuItemTwo" label="Menu Item Two" />
            <lightning:menuItem value="MenuItemThree" label="Menu Item Three" disabled="true" />
            <lightning:menuItem value="MenuItemFour" label="Menu Item Four" />
        </lightning:buttonMenu>
        
        <lightning:input lable='name' name='InputName'>
        </lightning:input>
        <lightning:formattedname
         firstName='{!v.InputName}'
         lastName='{!v.name}'                        
         />
       <p> 
        title styling
            css
                header class
    block for the form
        card
            card needs 
                open and close blocks for card
            
    fields for the form
        use attuributes above the form to define the fields
        use lightning input to create fields on the form using the attribute to assign the values that have been put in
    
    a button
        </p>
    </lightning:card>
    </div>
    <aura:attribute name="headerTitle" type="Aura.Component[]">
        <h2>
            <b>Watchlist (0)</b>
        </h2>
    </aura:attribute>
    
    <lightning:card footer="Card Footer" title="Hello">
        <aura:set attribute="actions">
            <lightning:button label="New"/>
        </aura:set>
        <p class="slds-p-horizontal_small">
            Card Body (custom component)
        </p>
    </lightning:card>
    
    <lightning:card variant="Narrow" title="Narrow Card Header" iconName="standard:account" footer="Card Footer">
        <aura:set attribute="actions">
            <lightning:buttonIcon iconName="utility:down" variant="border-filled" alternativeText="Show More"/>
        </aura:set>
        <p class="slds-p-horizontal_small">
            Card Body (custom component)
        </p>
    </lightning:card>

    <lightning:card class="slds-text-heading_small" 
        title="{!v.headerTitle}" iconName="utility:broadcast">
        <aura:set attribute="actions">
            <lightning:buttonMenu iconSize="x-small" menuAlignment="right">
                <lightning:menuItem label="Open Watchlist app" value="Open" />
                <lightning:menuItem label="Add to Watchlist app" value="Add" />
            </lightning:buttonMenu>
        </aura:set>
    </lightning:card>



    <div class="c-container">
        <lightning:layout >
            <lightning:layoutItem padding="around-small">
                <div class="header-column">
                    <p class="field-title" title="Field 1">Field 1</p>
                    <p>Name</p>
                </div>
            </lightning:layoutItem>
            <lightning:layoutItem padding="around-small">
                <div class="header-column">
                    <p class="field-title" title="Field2 (3)">Field 2 (3)
                        <lightning:buttonIcon iconName="utility:down" variant="border-filled" size="small" alternativeText="More Actions" />
                    </p>
                    <p>Eligibltiy</p>
                </div>
            </lightning:layoutItem>
            <lightning:layoutItem padding="around-small">
                <div class="header-column">
                    <p class="field-title" title="Field 3">Field 3</p>
                    <a href="#">Website</a>
                </div>
            </lightning:layoutItem>
            <lightning:layoutItem padding="around-small">
                <div class="header-column">
                    <p class="field-title" title="Field 4">Field 4</p>
                    <p>
                        <span title="">Address</span>
                    </p>
                </div>
            </lightning:layoutItem>
        </lightning:layout>
    </div>
</aura:component>
 

select statment is giving error ... pls help... AccountId, Status fields on case object. 
    public static Integer getCaseCount(String recId) {
        
        return [SELECT COUNT() FROM Case WHERE Status !='Closed' AND AccountId=recId];
        
    }
    
  • August 16, 2018
  • Like
  • 0
I have created an Apex Trigger to create a Task on the MVP Object but keep getting an error.

I am trying to link the Assigned To (Lookup(user,calender))  on the Task object to the MVP Owner (Lookup(user)). 

Can anyone help correct this error? 


User-added image
User-added image
I'm new to Salesforce and trying to understand Get, Set method.  I have written this simple code, where user can search for a record from custom object Attendance. Set method is not assigning the value to variable "Keyword".  Can someone explain what is the problem with my code?

Thank you

public class simplegetset
{  

    string keyword;
    list <attendance__c> att;
    
    public string getkeyword(){
    return keyword;
    }

    public list <attendance__C> getatt(){
     return att;
    }   
    
    Public void setKeyword(string s){
      keyword = s;
      }
      
     Public pagereference ShowResults(){
     att = [select contact__c, Manager__c, Manager_s_Manager__c,
               Approved__c,Attendance_Date__c, Hours__C,
              Is_Eligible_for_compensatory_off__c, AttendanceType__c FROM Attendance__c where contact__C = :keyword];
     return null;
     }
     
}
============================================================================

<apex:page controller="simplegetset">
  <apex:form >
   <apex:pageblock title="List of Employee Attendance">
   <apex:inputtext value="{!Keyword}"/>
   
   <apex:commandButton value="Show Results" action="{!ShowResults}" rerender="details"/>  
    <apex:pageblockTable value="{!att}" Var="a" id="details">
    <apex:column value="{!a.Contact__c}"/>
    <apex:column value="{!a.Manager__c}"/>
    <apex:column value="{!a.Manager_s_Manager__c}"/>
    <apex:column value="{!a.Approved__c}"/>  
    <apex:column value="{!a.Attendance_Date__c}"/>
    <apex:column value="{!a.Hours__c}"/>
    <apex:column value="{!a.AttendanceType__c }"/>    
   </apex:Pageblocktable>
   
   <apex:outputtext >{!keyword}
   </apex:outputtext> 
    </apex:pageblock>                
  </apex:form>    
</apex:page>

 
Hello All,

Hope you had a great weekend!
I have a problem in referring to custom setting data and checking if current logged in user name is there in the custom setting. Sounds simple to me but it seems I am doing some mistake and couldnt get the functionality working.
Here is the sample code
var user = sforce.connection.getUserInfo();
var customSettingUsers ="select name from Opportunity__c where name = '{!User.Name}' limit 1";
data = sforce.connection.query(customSettingUsers); 
var customSettingUsersData = data.getArray("records");
if(customSettingUsersData == '')
alert('Do you have a reason to click me? If yes contact your System Administrator with your reason');

I appreciate your help.

Thanks,
Srinivas​
Hi everyone, 

I want to auto populate new record in Quote when a new record is entered in the opportunity so that I am not entering information twice. But, all the fields in the opportuntiy are not there in Quotes. 
So, to achieve this I am trying to use Process Builder but cannot succeed. Do I need to use trigger for this?

Can someone please let me know how to do this?
Thanks for help.
Hello,

I am trying to display content from a JSON feed on my Salesforce page using APEX/visualforce page. From information gathered, I am able to get the details of the JSON on variable. But when running the visualforce page, I get the below error. Any help much appreciated..

Apex Code 
global class loraGeneralEventsController {

	public String title{get;set;}
	public String link{get;set;}
	public String event_date{get;set;}
	public location location{get;set;}
	public List<Items> dr{get;set;}

	public loraGeneralEventsController(){

	}

	public void requestM(){

		String url = 'https://www.semtech.com/company/events-json/lora-general-event';

		HttpRequest req = new HttpRequest();
		req.setEndpoint(url);
		req.setMethod('GET');

		Http http = new Http();
		HttpResponse res = http.send(req);
		String responseBody = res.getBody();
		system.debug('JSON Content : ' + responseBody);
		
		ResCls resItem = (ResCls)JSON.deserialize(responseBody, ResCls.class);
		List<Items> rl = resItem.items;
		system.debug('Item List : ' + resItem.items);
		dr = new List<Items>();
		for(Items it:rl){
			system.debug('Item Name: ' + it);
			title = it.title;
			link = it.link;
			system.debug('event_date: ' + it.event_date);
			system.debug('location: ' + it.location);
			dr.add(it);
		}   
	   system.debug('List: ' + dr);
	}

	public class ResCls{
		List<Items> items;
	}
		
	public class Items{

		public String title {get;set;}
		public String link {get;set;}
		public String event_date {get;set;}
		public String description {get;set;}
		public String location {get;set;}
		public String categories {get;set;}
		public String pubdate {get;set;}
	}


}

Visual force page :
<apex:page Controller="loraGeneralEventsController" action="{!requestM}" sidebar="false">
    <apex:pageBlock>
        <apex:pageblockSection >
            <apex:pageblockTable value="{!dr}" var="dd">
                    <apex:column headerValue="Title"><apex:outputText value="{!dd.title}"/></apex:column>
                    <apex:column headerValue="URL"><apex:outputText value="{!dd.link}"/></apex:column>
                    <apex:column headerValue="Date"><apex:outputText value="{!dd.event_date}"/></apex:column>
                    <apex:column headerValue="Location"><apex:outputText value="{!dd.location}"/></apex:column>
            </apex:pageblockTable>
        </apex:pageblockSection>
    </apex:pageBlock>
</apex:page>

Error that I get when runnig the page is 
 
Attempt to de-reference a null object
Error is in expression '{!requestM}' in component <apex:page> in page lorageneralevents: Class.loraGeneralEventsController.requestM: line 30, column 1

An unexpected error has occurred. Your development organization has been notified.

 

 
Hi All ,
I want to display all the contact names  in a drop down list but in contact list i need to remove duplicate Names .How can we achive this requirment .please find below code

public static list<contact> getconfigvalues(){
       
    return [select id ,name from contact ];
}


var action = component.get("c.getconfigvalues");
        action.setCallback( this, function(response) {
            var nameresult= response.getReturnValue();
            var state = response.getState();      
            if (state === "SUCCESS") {
         
                for(var key in nameresult){
                    namelist.push(nameresult[key[0]].Name);
                    
                }  
                component.set("v.Name",namelist) ; 

How to remove duplicate name from the namelist or Name attributr ?
How do I use VisualForce Component, Im struggling to wrap my head arond them. How are they called and refrenced and what Must I do to impliment a Save and Cancel function to my page?
<div class="slds-col slds-no-flex slds-grid slds-align-top">
                    <div class="slds-button-group" role="SPC">
                        <button class="slds-button slds-button_neutral">
                        	Save
                        </button>
                        <button class="slds-button slds-button_neutral" onclick="window.print();" >
                            Print
                         </button>
                        <button class="slds-button slds-button_neutral" >
                        	Cancel
                        </button>
                    </div>
                </div>
I expected It to be somthing like this -
<div class="slds-col slds-no-flex slds-grid slds-align-top">
                    <div class="slds-button-group" role="SPC">
                        <button class="slds-button slds-button_neutral" action="{!save}" >
                        	Save
                        </button>
                        <button class="slds-button slds-button_neutral" onclick="window.print();" >
                            Print
                         </button>
                        <button class="slds-button slds-button_neutral" >
                        	Cancel
                        </button>
                    </div>
                </div>

But I get this Error
Unknown property 'Apprentice__cStandardController.save'
Im using a Standard Controller so I have no clue why this error is appearing.
 
<apex:page standardController="Apprentice__c" title="Learning Agreement" showHeader="false" standardStylesheets="false" sidebar="false">
<head>
    <title>Apprentice Learning Agreement Form</title>
    <apex:slds />
</head>
<body>
    <div class="slds-scope">
        <div class="slds-page-header">
            <div class="slds-grid">   
                <div class="slds-col slds-has-flexi-truncate">
                    <div class="slds-media slds-no-space slds-grow">
                        <div class="slds-media__body">
                            <h1 class="slds-page-header__title slds-m-right_small slds-align-middle slds-truncate" title="Apprentice Learning Agreement">Apprentice Learning Agreement</h1>
                        </div>
                    </div>
                </div>     
<!-- PAGE HEADER / ROW 1 / COLUMN 2 -->
                <div class="slds-col slds-no-flex slds-grid slds-align-top">
                    <div class="slds-button-group" role="SPC">
                        <button class="slds-button slds-button_neutral" action="{!save}" >
                        	Save
                        </button>
                        <button class="slds-button slds-button_neutral" onclick="window.print();" >
                            Print
                         </button>
                        <button class="slds-button slds-button_neutral" >
                        	Cancel
                        </button>
                    </div>
                </div>


 
Getting error INVALID_TYPE: sObject type 'register__c' is not supported. While trying to create a user through the API. Profile  used is admin profile and all fields are appended rightly.
  • August 09, 2018
  • Like
  • 0
I am very new to Salesforce and the world of coding so please be very descriptive with your answers. Here is the code: 

trigger ContactSumTriggers on Contact (After insert, After delete, After undelete, After Update) {
   Set<Id> parentIdsSet = new Set<Id>();
   List<Account> accountListToUpdate = new List<Account>();
   IF(Trigger.IsAfter){
       IF(Trigger.IsInsert || Trigger.IsUndelete  || Trigger.isUpdate){
           FOR(Contact c : Trigger.new){
               if(c.AccountId!=null){   
                  parentIdsSet.add(c.AccountId);
                  If(Trigger.isUpdate){
                      if(Trigger.oldMap.get(c.Id).AccountId != c.AccountId){
                         parentIdsSet.add(Trigger.oldMap.get(c.Id).AccountId);
                      }
                   }
               }
           }
       }
       IF(Trigger.IsDelete){
           FOR(Contact c : Trigger.Old){
               if(c.AccountId!=null){   
                  parentIdsSet.add(c.AccountId);
               }
           }
       }
   }
   System.debug('#### parentIdsSet = '+parentIdsSet);
   List<Account> accountList = new List<Account>([Select id ,Name, Number_of_Contacts__c, (Select id, Name From Contacts) from Account Where id in:parentIdsSet]);
   FOR(Account acc : accountList){
       List<Contact> contactList = acc.Contacts;
       acc.Number_of_Contacts__c = contactList.size();
       accountListToUpdate.add(acc);
   }
   try{
       update accountListToUpdate;
   }catch(System.Exception e){
       
   }
}
User-added image
When I go to Validate to set live I get this problem, It dosnt show in the testing and It dosnt cause any issues in the sandbox. I was wondering if anyone could help me solve it?

Controller:-
public class PrintableView
{
   public final Apprentice__c App;
   public PrintableView(ApexPages.StandardController stdController) {
        this.App = (Apprentice__c)stdController.getRecord();
    }  
	public Apprentice__c ApprenticeObj{get;set;}
	public Programme_Area__c ProgramArea {get;set;}
	public Boolean bolPrintableView {get;set;}
           
    public void init() {
 	String strPrintableView = ApexPages.currentPage().getParameters().get('print');
 	bolPrintableView = (strPrintableView == '1');
        Programme_Area__c ProgramArea = new Programme_Area__c();
        ProgramArea.PA_Code__c = '112';
        insert ProgramArea;
        
	}
    public PrintableView(){
        ApprenticeObj = new Apprentice__c();
        ProgramArea = new Programme_Area__c();
        
    }
}
Test Class:-
@isTest

private class PrintViewTest {
    private Apprentice__c ApprenticeObj {get;set;}
    private Boolean bolPrintableView {get;set;}
    public PrintableView Pview {get;set;}
    public Programme_Area__c ProgramArea {get;set;}

    @istest Private Static void ApprenticeObjTest(){
       
		Programme_Area__c ProgramArea = new Programme_Area__c();
        ProgramArea.PA_Code__c = '112';
		insert ProgramArea;
	
		Apprentice__c ApprenticeObj = new Apprentice__c();
		ApprenticeObj.Date_of_Birth__c = date.parse('12/08/2000');
		ApprenticeObj.Programme_area__c = ProgramArea.Id;
		insert ApprenticeObj;
    }
    
    @istest Private Static void StandardTest(){
      Apprentice__c ApprenticeObj = new Apprentice__c();  
      Apexpages.StandardController sc = new Apexpages.standardController(ApprenticeObj);
      PrintableView PrintExt = new PrintableView(sc);
    }
     @istest Private Static void GetSetTest(){
        PrintableView Pview = new PrintableView();
        Pview.init();
        
        // check that an Apprentice__c was created
        List<Apprentice__c> ApprenticeObj = [SELECT Id FROM Apprentice__c];
        List<Programme_Area__c> ProgramArea = [SELECT Id FROM Programme_Area__c]; 
    }       
}

Thanks for any help

 
This for -
How to Code for Creating Validation Rule Challenge?

Rule needed - To complete this challenge, add a validation rule which will block the saving of a new or updated contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).
Name the validation rule Contact must be in Account ZIP Code
A contact with a MailingPostalCode that has an account and does not match the associated Account ShippingPostalCode should return with a validation error and not be saved
The validation rule should ONLY apply to contact records with an associated account. Contact records with no associated parent account can be added with any MailingPostalCode value. (Hint: you can use the ISBLANK function for this check)
What I have:
AND( NOT(ISBLANK(AccountId)), MailingPostalCode != Account.ShippingPostalCode )

Error I am getting-
Challenge not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Contract_End_Date__c]: [Contract_End_Date__c]

Unsure - I have the object Contract_End_Date__c (I have put it in ojects as a field for Account, Contact and Contract put it in all because i couldnt figure out the why?) and it is Required Field.

Thank you in advance,
Tom Smith
 
Hello,
We have a visualforce page which is used to input details about quality issues and create cases. I've created a custom case number field for newly created cases in an auto-numbered format. I've to create reports of these new cases based on it's status. Once I run the report, I want the custom case number to be rendered with a hyperlink, by which, I can directly browse to the case by clicking on the custom case number, just as the way for a standard case number. I would like to ignore the standard case numbers in reporting to avoid confusion among the users. How do I create the hyperlink? I want the below case numbers starting with QR to be in hyperlink. 

 User-added image
Finally got all the testing done for my Apex controller and got the print layout functioning as I wanted but a huge problem I have encounterd now is that my Visual Force Page isnt showing any data. What must I add to my Visualforce/Apex to show the values that I have in the fields.
User-added image
Ive had this problem before but couldnt figure it out. Here is some information It should be displaying.
User-added image

Here is my apex Class:-
public class PrintableView{   
public Apprentice__c ApprenticeObj{get;set;}
public Programme_Area__c ProgramArea {get;set;}
public Boolean bolPrintableView {get;set;}
       
    public void init() {
   String strPrintableView = ApexPages.currentPage().getParameters().get('print');
   bolPrintableView = (strPrintableView == '1');
  }
  
public PageReference save(){
if(ApprenticeObj != null){
} 
return null;
}
}
Visual Force componet used to make the print function:-
<apex:component controller="PrintableView" allowDML="true">
    public PrintableView(){ 
    ApprenticeObj = new Apprentice__c();
    ProgramArea = new Programme_Area__c ();
    ProgramArea.PA_Code__c = 'P12';
    insert ProgramArea;
    }
</apex:component>
And a small Snippet of the Visualforce Page
<apex:page lightningStyleSheets="True" Controller="PrintableView" title="Learning Agreement" showHeader="{!bolPrintableView}" sidebar="{!bolPrintableView}" action="{!init}">
    <apex:form >
    <apex:outputPanel rendered="{!NOT(bolPrintableView)}">
    <a href="/apex/Apprentice?print=1" target="_blank">Printable View</a>
</apex:outputPanel>

<apex:outputPanel rendered="{!bolPrintableView}">
    <script>
        window.print()
    </script>
</apex:outputPanel>

<apex:pageBlock >
         Learner ID :- <apex:inputField value="{! ApprenticeObj.Learner_Reference_Number__c }"/>
            <apex:pageBlockSection columns="3">
                <apex:inputField value="{! ApprenticeObj.Date_of_Birth__c}"/>
                <apex:inputField value="{! ApprenticeObj.Surname__c}"/>
                <apex:inputField value="{! ApprenticeObj.First_Name__c}"/>
                <apex:inputField value="{! ApprenticeObj.Middle_Other_Names__c}"/>
                <apex:inputField value="{! ApprenticeObj.Previous_Surname__c}"/>
                <apex:inputField value="{! ApprenticeObj.Preferred__c}"/>
                <apex:inputField value="{! ApprenticeObj.Gender__c}"/>
                <apex:inputField value="{! ApprenticeObj.ULN__c}"/>
                <apex:inputField value="{! ApprenticeObj.NI_Number__c}"/>
            </apex:pageBlockSection>
         </apex:pageBlock>

Thankyou for all and any help!

 
Hi 
I create a char with barSeries, but female bar is too short. Any idears?
User-added image
<apex:page >
    <apex:chart data="dataArray" width="500" height="200">
        <apex:axis type="Category" fields="gender" position="left" title="Gender"/>
        <apex:axis type="Numeric" fields="amount" position="bottom" title="PeopleAmount"/>
        <apex:barSeries axis="bottom" orientation="horizontal" xField="amount" yField="gender"/>
    </apex:chart>
    <script>
    	var dataArray = new Array();
        dataArray.push({'amount':1225,'gender':'Male'});
        dataArray.push({'amount':1189,'gender':'Female'});
    </script>
</apex:page>


 
Hi, I have two objects Parent__c and Child__c in Master-Detail relationship.
There is need that create a trigger on Child__c which can automatically create parent record when child records are insert or update.
Is that possible?
My understanding is a child record cannot be inserted without parent record ID.
I would like to launch an email composer from a visualforce commandLink as shown below. Any ideas? Would rather not create this
from scratch unless I have to.

User-added image
What attribute do we map a photo from active directory to populate a user's profile photo with Identity Connect?
Hello All,
I am facing below issue while pulling source from scratch org in salesforce dx. can someone please help me to configure dx properly.Thanks
ERROR:    specified in sfdx-project.json, does not exist. Be sure this directory is included in your project root.

User-added image
  • August 17, 2018
  • Like
  • 0
I have build a lightning component to list all the open cases and inserted in a page layout. But I want to hyperlink the case number, if someone clicks on that, it should take the user to the corresponding case for view/edit etc. can you pls let me know how to do this. thanks.
  • August 17, 2018
  • Like
  • 0
Guys,

I have downloaded a zipped file from a github repo. It contains many metadata components like an app, few classes, lightning components, custom labels etc. 
Is there anyway I can install this in my sandbox. I use Eclipse IDE currently. Unfortunately cannot use AppExchange and/or any third party tool. 

Thanks
Is there a built-in component attribute in any of the namespaces, (ie., lightning:, ui:, or force:, that has a search or lookup functionality to the Contact object record. The field I am working is in a lightning component, within a "form" component attribute.  

Here is a snapshot of the form component in top-level component. 

User-added image

This is a snapshot the custom field 'data type'

User-added image


The app works except when I enter data into the 'Client' field it will not save and create record.

Snapshot of my design.
User-added image

 
Hi all,

I would like to add another condition which forces the next step within a flow after a setCallback is reached;
 
action.setCallback(this, function(response) {
            var state = response.getState();
            console.log(response.getState());
            if (state === 'SUCCESS'){
                console.log('Response: ' + response.getReturnValue());
                var toastEvent = $A.get("e.force:showToast");
                toastEvent.setParams({
                    "title": "Success!",
                    "message": "entitlement applied.",
                    "type" : "success"
                });
                toastEvent.fire();
                component.find("overlayLib").notifyClose();
                navigate("NEXT");


Any idea what the correct call would be here? 

Thanks
 

I want to get all contact filed label and API names using rest call. But I didn't find any endpoint for this.

Please tell me how to get it?

Hi, I'm getting the same error on all the code I try for  the Trailhead Challenge 'Create a unit test for a simple Apex Class'.

The error I get is: Method does not exist or incorrect signature: void CheckDates(Date, Date) from the type VerifyDate

I have tried the following:

@isTest
private class TestVerifyDate {
    
    static testMethod void TestVerifyDates() {
        VerifyDate.CheckDates(system.today(),system.today().addDays(10));
        
        VerifyDate.CheckDates(system.today(),system.today().addDays(78));
       
    }

}


Also:

@isTest
public class TestVerifyDate {
    @isTest static void testVerifyDate(){
        date date1=VerifyDate.CheckDates(system.today(),system.today().addDays(10));
        System.assertEquals(system.today().addDays(10),date1);
        
        date date2=VerifyDate.CheckDates(system.today(),system.today().addDays(78));
        System.assertEquals(system.today(),date2);
    }
}


Also:

@isTest
private class TestVerifyDate{
    @isTest static void testDt1GtrDt2(){
        Date d2 = system.today();
        Date d1 = d2.addDays(10);
        
        Date dt = VerifyDate.CheckDates(d1, d2);
        Date testDt = Date.newInstance(2017, 7, 31);
        System.assertEquals(dt, testDt);
    }
    
    @isTest static void testDt2Within30dayOfDt1(){
        Date d1 = system.today();
        Date d2 = d1.addDays(10);
        
        Date dt = VerifyDate.CheckDates(d1, d2);
        System.assertEquals(dt, d2);
    }
}


This is the code for the Class itself:

public class VerifyDate {
//method to handle potential checks against two dates
public static Date CheckDates(Date date1, Date date2) {
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2)) {
return date2;
} else {
return SetEndOfMonthDate(date1);
}
}
//method to check if date2 is within the next 30 days of date1
private static Boolean DateWithin30Days(Date date1, Date date2) {
//check for date2 being in the past
if( date2 < date1) { return false; }
//check that date2 is within (>=) 30 days of date1
Date date30Days = date1.addDays(30); //create a date 30 days away from date1
if( date2 >= date30Days ) { return false; }
else { return true; }
}
//method to return the end of the month of a given date
private static Date SetEndOfMonthDate(Date date1) {
Integer totalDays = Date.daysInMonth(date1.year(), date1.month());
Date lastDay = Date.newInstance(date1.year(), date1.month(), totalDays);
return lastDay;
}
}

Can anyone point me to what I am doing wrong please?

Thanks!




 
/**
* @name OrderExtension
* @description This class is provided for you to facilitate the Super Badge
**/
public class OrderExtension {
    
    public Order orderRecord {get;set;}
    public List<OrderItem> orderItemList {get;set;}
    public String selectedFamily {get;set;}
    public List<chartHelper.chartData> pieData {get;set;}
    public Decimal total {get;set;}
    public Map<Id,OrderItem> orderItemMap;
    ApexPages.StandardSetController standardSetController;
    public OrderExtension(ApexPages.StandardController standardController){
        orderRecord = (Order)standardController.getRecord();
        orderItemMap = new Map<id,OrderItem>();
        if ( orderRecord.Id != null ){
            orderRecord = queryOrderRecord(orderRecord.Id);
        }
        resetSsc();
        total = 0;
        for (OrderItem oi : orderRecord.OrderItems) {
            orderItemMap.put(oi.Product2Id, oi);
            if (oi.Quantity > 0) {
                if (null == pieData) {
                    pieData = new List<ChartHelper.ChartData>();
                }
                pieData.add(new chartHelper.ChartData(oi.Product2.Name, oi.Quantity * oi.UnitPrice));
                total += oi.UnitPrice * oi.Quantity;
            }
        }
        PopulateOrderItems();
    }
    void resetSsc() {
        String query = 'SELECT Name, Product2.Family, Product2.Name, Product2Id, UnitPrice, Product2.Quantity_Remaining__c'
            + '  FROM PricebookEntry WHERE IsActive = TRUE';
        if (selectedFamily != null && selectedFamily != Constants.SELECT_ONE) {
            query += ' AND Product2.Family = \'' + selectedFamily + '\'';
        }
        query += ' ORDER BY Name';
        standardSetController = new ApexPages.StandardSetController(Database.getQueryLocator(query));
        standardSetController.setPageSize(Constants.DEFAULT_ROWS);
    }
    //ToDo: Implement your own method to populate orderItemList
    //  that you will call after pagination and/or family selection
    void PopulateOrderItems() {
        orderItemList = new List<OrderItem>();
        for (SObject obj : standardSetController.getRecords()) {
            PricebookEntry pbe = (PricebookEntry)obj;
            
            if (orderItemMap.containsKey(pbe.Product2Id)) {
                orderItemList.add(orderItemMap.get(pbe.Product2Id));
            } else {
                orderItemList.add(new OrderItem(
                    PricebookEntryId=pbe.Id,
                    Product2Id=pbe.Product2Id,
                    UnitPrice=pbe.UnitPrice,
                    Quantity=0,
                    Product2=pbe.Product2
                ));
            }
        }
    }
    /**
* @name OnFieldChange
* @description
**/
    public void OnFieldChange(){
        //ToDo: Implement logic to store the values changed on the page
        for (OrderItem oi : orderItemList) {
            orderItemMap.put(oi.Product2Id, oi);
        }
        //      and populate pieData
        pieData = null;
        total = 0;
        for (OrderItem oi : orderItemMap.values()) {
            if (oi.Quantity > 0) {
                if (null == pieData) {
                    pieData = new List<chartHelper.ChartData>();
                }
                pieData.add(new chartHelper.ChartData(oi.Product2.Name, oi.Quantity * oi.UnitPrice));
                //      and populate total
                total += oi.UnitPrice * oi.Quantity;
            }
        }
    }
    /**
* @name SelectFamily
* @description
**/
    public void SelectFamily(){
        //ToDo: Implement logic to filter based on the selected product family
        resetSsc();
        PopulateOrderItems();
    }
    /**
* @name Save
* @description
**/
    public void Save(){
        //ToDo: Implement logic to save the Order and populated OrderItems
        System.Savepoint sp = Database.setSavepoint();
        try {
            if (null == orderRecord.Pricebook2Id) {
                orderRecord.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            }
            upsert orderRecord;
            List<OrderItem> orderItemsToUpsert = new List<OrderItem>();
            List<OrderItem> orderItemsToDelete = new List<OrderItem>();
            for (OrderItem oi : orderItemList) {
                if (oi.Quantity > 0) {
                    if (null == oi.OrderId) {
                        oi.OrderId = orderRecord.Id;
                    }
                    orderItemsToUpsert.add(oi);
                } else if (oi.Id != null) {
                    orderItemsToDelete.add(oi);
                }
            }
            upsert orderItemsToUpsert;
            delete orderItemsToDelete;
        } catch (Exception e) {
            Database.rollback(sp);
            apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,Constants.ERROR_MESSAGE));
        }
    }
    /**
* @name First
* @description
**/
    public void First(){
        standardSetController.first();
        PopulateOrderItems();
    }
    /**
* @name Next
* @description
**/
    public void Next(){
        standardSetController.next();
        PopulateOrderItems();
    }
    
    
    /**
* @name Previous
* @description
**/
    public void Previous(){
        standardSetController.previous();
        PopulateOrderItems();
    }
    /**
* @name Last
* @description
**/
    public void Last(){
        standardSetController.last();
        PopulateOrderItems();
    }
    /**
* @name GetHasPrevious
* @description
**/
    public Boolean GetHasPrevious(){
        return standardSetController.getHasPrevious();
    }
    
    /**
* @name GetHasNext
* @description
**/
    public Boolean GetHasNext(){
        return standardSetController.getHasNext();
    }
    
    /**
* @name GetTotalPages
* @description
**/
    public Integer GetTotalPages(){
        return (Integer)Math.ceil(standardSetController.getResultSize() / (Decimal)Constants.DEFAULT_ROWS);
    }
    
    /**
* @name GetPageNumber
* @description
**/
    public Integer GetPageNumber(){
        return standardSetController.getPageNumber();
    }
    
    /**
* @name GetFamilyOptions
* @description
**/
    public List<SelectOption> GetFamilyOptions() {
        List<SelectOption> options = new List<SelectOption>{
            new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE)
                };
                    
                    for (Schema.PicklistEntry ple : Constants.PRODUCT_FAMILY) {
                        options.add(new SelectOption(ple.getValue(), ple.getLabel()));
                    }
        return options;
    }
    
    /**
* @name QueryOrderRecord
* @description
**/
    public static Order QueryOrderRecord(Id orderId){
        return [
            SELECT Id, AccountId, EffectiveDate, Name, Status, Pricebook2Id,
            (
                SELECT Id, OrderId, Quantity, UnitPrice, PricebookEntryId, Product2Id,
                Product2.Name, Product2.Family, Product2.Quantity_Remaining__c
                FROM OrderItems
            )
            FROM Order
            WHERE Id = :orderId
        ];
    }
}
Hello Experts,
Need test class for following VF page that display a registeration form with name,roll number,gender fields. all save the result and display form in multiple language.

--------------------------VF PAGE-------------------------------
<apex:page standardController="Student__c" extensions="StudentRegFormExtension" language="{!selectedLang }"
    sidebar="false" 
>
    <apex:form >
        <apex:selectList value="{!selectedLang}" size="1">
            <apex:selectoptions value="{!listOfLang}"/>
            <apex:actionsupport event="onchange" reRender="form"/>
        </apex:selectlist>

        <apex:outputPanel id="pageMessage">
            <apex:pageMessages rendered="true" ></apex:pageMessages>
        </apex:outputPanel>

        <apex:pageblock >
                <apex:pageblocksection id="form">
                    <apex:inputfield value="{! Student__c.Name }"/>
                    <apex:inputfield value="{! Student__c.Roll_Number__c }"/>
                   
                    <apex:inputfield value="{! Student__c.Gender__c }"/>
                    <apex:inputfield value="{! Student__c.Course_Applying_For__c }"/>
                    <apex:inputfield value="{! Student__c.State__c }"/>
                    <apex:inputfield value="{! Student__c.Country__c }"/>
                </apex:pageblocksection>
                <div align="center" draggable="false" >
                       <apex:commandButton value="{!$Label.Record_Inserted}" action="{! save}" reRender="pageMessage"/>
                       </div>
        </apex:pageblock>
    </apex:form>
</apex:page>
-------------------------------------------Controller------------------------------------------


public class StudentRegFormExtension {
    
    public Boolean showMessage{get;set;}
    public String selectedLang{get;set;}
    public List<SelectOption> listOfLang {get;set;}
    public ApexPages.StandardController controller{get;set;}
  
    
    public StudentRegFormExtension(ApexPages.StandardController con) {
       controller = con;
       showMessage = false;
        listOfLang = new List<SelectOption>();
        listOfLang.add(new SelectOption('en','English'));
        listOfLang.add(new SelectOption('es','Spanish'));
        listOfLang.add(new SelectOption('fr','French'));
     if(ApexPages.currentPage().getParameters().get('Success') != null ) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,
            System.Label.Record_Inserted));
       
    }
    }
    
     public PageReference save() {

        Student__c student = (Student__c)controller.getRecord();
        PageReference pr;
        if(student.Name == null) {
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,
                System.Label.Error_Inserting_Record));

        }else {
            controller.save();
            pr = new PageReference('/apex/StudentRegForm?Success=true');
            pr.setRedirect(true);
        }
        return pr;
    }
    
}
Hello Experts,
Need test class for following VF page that display a dependent picklist which is a customSetting. Consider all positive negative test cases

--------------------------VF PAGE-----------------------------
<apex:page controller="CountryDependentController" showHeader="true" sidebar="false">    
    <apex:pageBlock >
        <apex:form >
        <!-- actionFunction -->
            <apex:actionFunction action="{!getCountrylist}" name="rerenderCities" rerender="Cities" >
                <apex:param name="firstParam" assignTo="{!country}" value="" />
            </apex:actionFunction>
            
            <!-- SelectList-->
            Country :   <apex:selectList value="{!country}" size="1" onchange="rerenderCities(this.value)">
                            <apex:selectOptions value="{!CountryList}"></apex:selectOptions>
                        </apex:selectList> <br/> <br/>
            City :      <apex:selectList id="Cities" value="{! cities}" size="1">
                            <apex:selectOptions value="{!CityList}"></apex:selectOptions>
                        </apex:selectList>
        </apex:form>
    </apex:pageBlock>
</apex:page>

------------------------------------CONtroller--------------------------------------------------
 public class CountryDependentController {
        Map<String, Country__c> countryMap = Country__c.getall();
        public String cities{ get; set; }
        public String country{ get; set;}
    
    public List<SelectOption> getCountrylist() {
    
    /* Method will give list of countries   
     * @param: NA
     * @return: selectoption: The country which will be selected by user will be returned
     */ 
        List<SelectOption> selectoptionList = new List<SelectOption>();
        for(String country : countryMap.keySet()){
        selectoptionList.add(new selectoption(country,country));
        }
        return selectoptionList;
        }
    
    /* Method will give list of cities   
     * @param: NA
     * @return: selectoptionList: Based on selected country user can select any city related to that country.
     */     
    public List<SelectOption> getCityList() {      
    List<SelectOption> selectoptionList = new List<SelectOption>();
        if( country == null ) {
            return selectoptionList;
        } else {
    List<City__c> cityList = City__c.getAll().values();
            for(City__c city : cityList) {
                if(city.Country__c == country ) {
                    selectoptionList.add(new selectoption(city.Name, city.Name));
                } 
            }
        }
        return selectoptionList;
        }
    } 
Hi all.

I'm now using Sublime Text3 with MavensMate and heard that there is eclipse force.com IDE.
If there are some other develop tools, could you please let me know and suggest me what you think the best among them.

Thanks in advance,
@isTest
public class PagingDemoWithAlpabetsTest {
  

  /**
    This method tests Searching functionality of AlphabeticSearchExtension.
    @return Nothing.
   */
  @isTest 
  public static void testSearch() {
    PageReference pageRef = Page.ContactAlphaSearch;
    Contact contactObject = new Contact(LastName='Eternus');
    ApexPages.StandardController StandardControllerObject = new ApexPages.StandardController(contactObject);
    PagingDemoWithAlpabets alpabetsTestObject = new PagingDemoWithAlpabets(StandardControllerObject);
    PagingDemoWithAlpabets.SearchVar = 'A';

    pageRef.getParameters().put('Alphabet','T');
   // Test.setCurrentPage(pageRef);

    System.Test.startTest();
    PagingDemoWithAlpabets.display();
    System.Test.stopTest();

    System.assertEquals(0,size, 
      'PagingDemoWithAlpabets Failed for Searching');
  }

  /**
    This method tests Searching functionality of AlphabeticSearchExtension for Alphabets.
    @return Nothing.
   */
   
  @isTest static void testSearchAlpha() {
    PageReference pageRef = Page.ContactAlphaSearch;
    pageRef.getParameters().put('Alphabet','A');
    Test.setCurrentPage(pageRef);
    AlphabeticSearchExtension searchExtension = new AlphabeticSearchExtension();

    Test.startTest();
    searchExtension.search();
    Test.stopTest();

    System.assertEquals(searchExtension.renderTable, false, 
      'AlphabeticSearchExtension Failed for Searching A characher');
  }

  /**
    This method tests Searching functionality of AlphabeticSearchExtension for No parameter.
    @return Nothing.
   */
  @isTest static void testSearchNoParam() {
    PageReference pageRef = Page.ContactAlphaSearch;
    Test.setCurrentPage(pageRef);
    AlphabeticSearchExtension searchExtension = new AlphabeticSearchExtension();

    Test.startTest();
    searchExtension.search();
    Test.stopTest();

    System.assertEquals(searchExtension.renderTable, false, 
      'AlphabeticSearchExtension Failed for Searching  No parameter');
  }

  /**
    This method tests Searching functionality of AlphabeticSearchExtension for All character.
    @return Nothing.
   */
  @isTest static void testSearchAll() {
    PageReference pageRef = Page.ContactAlphaSearch;
    pageRef.getParameters().put('Alphabet','All');
    Test.setCurrentPage(pageRef);
    AlphabeticSearchExtension searchExtension = new AlphabeticSearchExtension();

    Test.startTest();
    searchExtension.search();
    Test.stopTest();

    System.assertEquals(searchExtension.renderTable, false, 
      'AlphabeticSearchExtension Failed for Searching All characher');
  }

  /**
    This method tests Searching functionality of AlphabeticSearchExtension for Other than Alphabets.
    @return Nothing.
   */
  @isTest static void testSearchOther() {
    PageReference pageRef = Page.ContactAlphaSearch;
    pageRef.getParameters().put('Alphabet','Other');
    Test.setCurrentPage(pageRef);
    AlphabeticSearchExtension searchExtension = new AlphabeticSearchExtension();

    Test.startTest();
    searchExtension.search();
    Test.stopTest();

    System.assertEquals(searchExtension.renderTable, false, 
      'AlphabeticSearchExtension Failed for Searching Other characher');
  }

  /**
    This method tests deletion functionality of AlphabeticSearchExtension.
    @return Nothing.
   */
  @isTest static void testDelete() {
    PageReference pageRef = Page.ContactAlphaSearch;
    List<Contact> contactRecord = TestDataFactory.createContact(1);
    insert contactRecord;
    Test.setCurrentPage(pageRef);

    Test.startTest();
    AlphabeticSearchExtension.deleteContact(contactRecord[0].id);
    Test.stopTest();

    contactRecord = [
      SELECT
        id
      FROM
        Contact
    ];

    System.assertEquals( contactRecord.size(), 0, 
      'AlphabeticSearchExtension Failed for Delete contact functionality.');
  }

}
User-added image
Hi
I am having trouble to set the default value for the dependent picklist in lightning by using the createRecordEvent + defaultFieldValues. I have a custom button to create new opportunity and it will grab data from account and pre-fill in opportunity. Everything works except the dependent picklist and seem like the field is lock in lightning and I can't figure a way to pre-select the value for the user. And the dependent picklist is a required field so the user has to fill in something so workflow may not be ideal for this case. Does anyone has any ideas? Please help!!

            createRecordEvent.setParams({
                "entityApiName": "Opportunity",
                "recordTypeId":rtDet.id,
                "defaultFieldValues": {
                    'AccountId' : Account.Id ,
                    'CurrencyIsoCode' : Account.CurrencyIsoCode,
                    'Type' : OpportunityType,
                    'City__c' : Account.City__c,
                    'Region__c' : Account.Region_n__c
                }
            });
I have a requirement that ananymous user who doesn't requre login to access a page, fills the details, saves to an object (custom, and it has lookup field  to contact) . For this I have done the below steps
  • Added Domain
  • Created new Site
  • Assigned the created VF page in to the list 'Site Visualforce Pages'
  • Activated the site
  • Gave perrmissions (RWA) to the custom object
But when I click on the page I got the following error
Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it.
We should directly access to the page without authorize, how can we do this?
Thanks,