• Thulasi Reddys
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 11
    Replies
Apex Class:
public with sharing class OpportunitySaveCtrl
{
    /**
   * Create a new Opportunity Record
   *
   * @param WorkOrder Opportunity Opportunity record to be inserted
   * 
   */
   
    public static list<opportunity> opportunity{get;set;}
    
    @AuraEnabled public static List<String> sssPickvalues{get;set;}
    
     @AuraEnabled public static List<String> cctypePickvalues{get;set;}
   
    @AuraEnabled
   public static String createRecord(Opportunity opportunity)
    {
        try
        {
            System.debug('OpportunitySaveCtrl::createRecord::opportunity'+opportunity);
           
            if(opportunity!= null)
                insert opportunity;
        } 
        catch (Exception ex)
        {
            
        }
        return null; 
      
    } 
   
         public static List<String> getServicesspickvalue()
    {
        sssPickvalues = new List<String>();
        
        Sobject ss = new opportunity();
        String sssfield='LeadSource';
        
        sssPickvalues.add('--None--');
        sssPickvalues.addall(getselectOptions(ss,sssfield));
        
        return sssPickvalues;
    }
    
    @AuraEnabled
    public static List<String> getcctypepickvalue()
    {
        cctypePickvalues= new List<String>();
        
        Sobject ss = new opportunity();
        String sssfield='StageName';
        
        cctypePickvalues.add('--None--');
        cctypePickvalues.addall(getselectOptions(ss,sssfield));
        
        return cctypePickvalues;
    } 
     
  
    
     @AuraEnabled
     public static List <String> getselectOptions(sObject objObject, string fld) 
     {
          List <String> allOpts = new list <String>();
          Schema.sObjectType objType = objObject.getSObjectType();  // Get the object type of the SObject.
          Schema.DescribeSObjectResult objDescribe = objType.getDescribe();  // Describe the SObject using its object type.
          Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();  // Get a map of fields for the SObject
          List <Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();  // Get the list of picklist values for this field.
        
          for(Schema.PicklistEntry a: values) 
           allOpts.add(a.getValue());  // Add these values to the selectoption list.
        
          allOpts.sort();
          return allOpts;
     }
           
}

Component:
<aura:component controller="OpportunitySaveCtrl" 
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" 
                access="global" >
    
    <!-- Include Static Resource-->
    <ltng:require styles="/resource/bootstrap1/css/bootstrap.min.css" 
                  scripts="/resource/bootstrap1/js/jquery.js,/resource/bootstrap/js/bootstrap.min.js"/>
    
    <!-- Define Attribute-->
    <aura:attribute name="selectedLookUpRecord" type="sObject" default="{}"/>
    <aura:attribute name="selectedLookUpRecord1" type="sObject" default="{}"/>
    <aura:attribute name="selectedLookUpRecord2" type="sObject" default="{}"/>
    <aura:attribute name="number" type="integer"/>
    <aura:attribute name="myText" type="String"/>

    <aura:attribute name="opportunity" type="Opportunity" default="{'sobjectType': 'Opportunity',
                                                                  'Name': '',
                                                                  'Account__c': '',
                                                                  'Primary_Contact__c': '',
                                                                  'Work_Order__c': '',
                                                                  'LeadSource': '',
                                                                  'StageName' : '',
                                                                  'CloseDate': '',
                                                                  'Priority__c' : '',                                                                                                                                    
                                                               }"/><br/>
    <div style="background-color:white;padding:10pt;border-radius:5px;">
    	<div>
            <table>
                <tr>
                    <td>
                        <h2 style="font-weight:bold;font-size:12px;margin-left:5%">New Opportunity Edit</h2>
                        <h1 style="font-weight:bold;font-size:18px;margin-left:5%">New Opportunity</h1>
                    </td>
                </tr>
            </table>
    </div><br/>
    <center>
    	<!--<div class="col-md-4 text-center">
      		<lightning:button variant="brand" label="Save" onclick="{!c.create}"/>
        </div>-->
        <lightning:button variant="brand" label="Save" onclick="{!c.create}"/>
         <lightning:button variant="brand" label="Cancel" onclick="{!c.cancel}"/>
    </center><br/>
   <!-- <div class="slds-box" style="background:rgb(0, 161, 223);font-weight:bold;font-size:15pt;">
        <p>Opportunity Information</p>
    </div>-->
        <h3 class="slds-section__title slds-theme_shade">
            <span class="slds-truncate slds-p-horizontal_small" title="Address Information">Opportunity Information</span>
     </h3>
    
    <div class="slds-grid slds-gutters">
        <div class="slds-col" style="width:500px;">
            <table class="slds-table slds-table--bordered slds-table--cell-buffer"> 
              <thead>
         		<tr>
                 <td>
                  <table>
                      <tr>
                    	<td><p class="title">Opportunity Name</p>
            		<ui:inputText value="{!v.opportunity.Name}"/></td>
                    </tr>
                      <tr>
                    	<td><c:customLookup objectAPIName="account" IconName="standard:account" label="Account Name" selectedRecord="{!v.selectedLookUpRecord}"/></td>
                    </tr>
                    
                      <tr>
                    	<td><c:customLookup objectAPIName="WorkOrder" IconName="standard:workOrder" label="Work Order" selectedRecord="{!v.selectedLookUpRecord2}"/></td>
                    </tr>
                    <tr>
                    	<td><c:customLookup objectAPIName="contact" IconName="standard:contact" label="Primary Contact" selectedRecord="{!v.selectedLookUpRecord1}"/></td>
                    </tr>
                        <div class="form-group">
                            <tr>
                            <td>
                        <p class="title">Lead Source</p>
                        <ui:inputSelect class="single" aura:id="InputSelectSingle" change="{!c.onSingleSelectChange}"  value="{!v.opportunity.LeadSource}">
                            <ui:inputSelectOption text="Web"/>
                            <ui:inputSelectOption text="External Referral"/>
                            <ui:inputSelectOption text="Trade Show"/>
                            <ui:inputSelectOption text="Public Relations"/>
                        </ui:inputSelect>
                     </td>
                     </tr>
                    </div>      
                     
                    </table>
                    </td>
                    <td> 
                        <table>
                        <tr>
                            <td>
                        <p class="title">Stage</p>
                        <ui:inputSelect class="single" aura:id="InputSelectSingle" change="{!c.onSingleSelectChange}"  value="{!v.opportunity.StageName}">
                            <ui:inputSelectOption text="Closed Won"/>
                            <ui:inputSelectOption text="Closed Lost"/>
                            <ui:inputSelectOption text="Patriot Suggestion"/>
                            <ui:inputSelectOption text="Agree to Proceed"/>
                        </ui:inputSelect>
                     </td>
                         </tr>
                         <tr>
                            <td>
                        <label>Close Date</label>
                    	<ui:inputDate aura:id="mySelectedDate" displayDatePicker="true" value="{!v.opportunity.CloseDate}"/>
                       		</td>
                         </tr>  
                    <div class="form-group">
                        <tr>
                         <td>
                        <p class="title">Priority</p>
                        <ui:inputSelect class="single" aura:id="InputSelectSingle" change="{!c.onSingleSelectChange}"  value="{!v.opportunity.Priority__c}">
                            <ui:inputSelectOption text="Low"/>
                            <ui:inputSelectOption text="Medium"/>                 
                            <ui:inputSelectOption text="High"/>
                            <ui:inputSelectOption text="Critical"/>                          
                        </ui:inputSelect>
                    	</td>
                      </tr>
                       
                     </div>                                        
                </table>
                </td>
               
                  </tr>
                </thead>
            </table>           
        </div>		          
      </div>
    </div>
</aura:component>
Controller:
({
    create : function(component, event, helper) {
        console.log('Create record');
        
        //getting the candidate information
        var opportunity = component.get("v.opportunity");
        opportunity.Account__c = null;
        opportunity.Primary_Contact__c = null;
        opportunity.Work_Order__c = null;
        
        /***************Validation
        if($A.util.isEmpty(workorder.Opportunity__c) || $A.util.isUndefined(workorder.Opportunity__c)){
            alert('Account Name is Required');
            return;           
        }*************************************************/
        if(component.get("v.selectedLookUpRecord").Id != undefined){
            opportunity.Account__c = component.get("v.selectedLookUpRecord").Id;
        }
        if(component.get("v.selectedLookUpRecord1").Id != undefined){
            opportunity.Primary_Contact__c = component.get("v.selectedLookUpRecord1").Id;
        }
        if(component.get("v.selectedLookUpRecord2").Id != undefined){
            opportunity.Work_Order__c = component.get("v.selectedLookUpRecord2").Id;
        }
        
        //Calling the Apex Function
        var action = component.get("c.createRecord");
        
        //Setting the Apex Parameter
        action.setParams({
            opportunity : opportunity
        });
        
        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            
            //check if result is successfull
            if(state == "SUCCESS"){
                //Reset Form
                var newOpportunity = {'sobjectType': 'Opportunity',
                                    'Name': '', 
                                    'Account__c': '',
                                    'Primary_Contact__c': '',
                                    'Work_Order__c': '',
                                    'StageName' : '',
                                    'CloseDate': '',
                                    'Priority__c' : '',
                                   
                                    
                                   };
                //resetting the Values in the form
                component.set("v.opportunity",newOpportunity);
                alert('Record is Created Successfully');
            } else if(state == "ERROR"){
                alert('Error in calling server side action');
            }
        });
        
        //adds the server-side action to the queue        
        $A.enqueueAction(action);
        
    },
    
	 onSingleSelectChange: function(cmp,event,helper) {
        var selectCmpValue = event.getSource().get("v.value");
       
    },
	 /***onSingleSelectChange: function(cmp) {
         var selectCmp = cmp.find("InputSelectSingle");
         var resultCmp = cmp.find("singleResult");
         resultCmp.set("v.value", selectCmp.get("v.value"));
	 },***************/
	 onChange: function(cmp) {
		 var dynamicCmp = cmp.find("InputSelectDynamic");
		 var resultCmp = cmp.find("dynamicResult");
		 resultCmp.set("v.value", dynamicCmp.get("v.value"));
	 }
})

 
I tried a simpe code to display a list of contacts in vfpage
public class Payment {
public List<Contact> ls{get;set;}
public Set<String> st{get;set;}
public string str{get;set;}


    public Payment(){
    List<Contact> ls = new List<Contact>();
    ls = [select id, name from contact limit 3];
    Set<String> st = new Set<String>();
    st.add('1111111');
    st.add('addad');
    st.add('gxghdy');
    st.add('6366vx');
    str = '123';
    
    }
}

<apex:page controller="Payment">
    {!ls}{!st}{!str}
    <apex:pageBlock >
        <apex:pageBlockTable value="{!ls}" var="a">
            <apex:column value="{!a.name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
User-added image
checked all sharing settings every thing is public
this is my new dev edition signedup today
i had same issue with one signed up this month
is this a bug or an issue with my code

--- I can see contacts in debug logs
 
  • March 10, 2018
  • Like
  • 0
I am trying to make a Custom Lightning Component which will render a lightning view page into a PDF  on click of a button. I have tried using jsPDF function of javascript but would not achieve it. 
Please suggest any other way of achieving this functionality in lightning. Help will be appreciated.

Thank You.

Hi All,

 

I require an urgent help.

 

The requirement is that i need to provide a custom button on the Default List View Page to send an Email to the selected record's Email Id field.

 

The records will be selected using the Action Checkbox provided i.e. i need to check the CheckBox provided under Action column to select the records, and after selecting the records click on the Custom button to send the Email to all.

 

Can it be done, if yes please let me know How....Its urgent Please..