• sheila srivatsav
  • NEWBIE
  • 180 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 15
    Replies
My requirement is to display Account and its related contacts using accordion and accordion section.

I am able to display account and when I expand account it will show Rating and Phone but Under each account I want a separate accordion to show contact firstname and contact lastname.

Here's my code
public with sharing class MyController {

    @AuraEnabled
    public static List<Account> showAccountsForAccordion()
    {
        List<Account> accList = [select Id,Name,Rating,Phone,(select firstname,lastname from contacts)
                                 FROM 
                                 Account
                                 Order By name LIMIT 4];
        return accList;
    }
}

<aura:component implements="flexipage:availableForAllPageTypes" 
                controller="MyController"
                access="global" >
	
    <aura:attribute name="accnList"
                    type="List"/>
    
    <aura:handler name="init"
                  value="{!this}"
                  action="{!c.doInit}"/>
    
    <div class="demo-only slds-grid" style="height: 150px; width: 300px; padding: 2rem;">
    <div class="slds-is-fixed">
    <div style="position: absolute; top: 1rem; left: 1rem; border: 1px solid red; background: rgb(244, 246, 249);">
    
    <lightning:accordion>
          <aura:iteration items="{!v.accnList}" 
                          var="acc">
              
              <lightning:accordionSection name="{!acc.Name}" 
                                          label="{!acc.Name}">
                  
                   <aura:set attribute="body">
                       
                        <p>Rating : {!acc.Rating}</p>
                        <p>Phone : {!acc.Phone}</p>
                      
                    </aura:set>
                  
                  </lightning:accordionSection>
              
              <aura:iteration items="{!v.accnList.contacts}" 
                                  var="con">
                  <lightning:accordionSection name="{!con.Name}" 
                                              label="{!con.Name}">
                  
                   <aura:set attribute="body">
                       
                        <p>FirstName : {!con.FirstName}</p>
                        <p>LastNamePhone : {!con.LastName}</p>
                      
                    </aura:set>
                   </lightning:accordionSection>
                       </aura:iteration>
      </aura:iteration>
      </lightning:accordion>
  </div>
</div>
         </div>
</aura:component>


({
	doInit : function(component, event, helper) {
		
        debugger;
        var action=component.get('c.showAccountsForAccordion');
        
        action.setCallback(this,function(response){
            
            debugger;
            var state = response.getState();
            console.log('state ='+state);
            if (component.isValid() && state === "SUCCESS") {
               
                component.set("v.accnList", response.getReturnValue());
                console.log('v.accnList='+response.getReturnValue());
              }
        });$A.enqueueAction(action);
        
	}
})

Please tell me how to achieve this.

thanks
sheila
I am tring to get my basics clear while making an api call from lightning application.

But when I debug the statement  var action=resposne.getState(), the state is ERROR
 
public class httpCalloutController {

    @AuraEnabled
    public static void getCalloutResponseContents()
    {
        Http h = new Http();
      
        HttpRequest req = new HttpRequest();
		req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
		req.setMethod('GET');      
        
        // Send the request, and return a response
		HttpResponse res = h.send(req);
		System.debug('response:--> ' + res.getBody());
        
        
        string jsonstring=(string)JSON.deserializeUntyped(res.getBody());
        system.debug('jsonstring-->' + jsonstring);
     }
}

CalloutComponent.cmp

<aura:component implements="flexipage:availableForAllPageTypes" 
                access="global"
                controller="httpCalloutController">
    
    <aura:attribute name="response" type="string"/>
    
	<aura:attribute name="jsonoutput" type="String[]"/>
    
    <lightning:button label="Make Callout" 
                      title="Make Callout"
                      onclick="{!c.MakeCallOut}"/>

    {!jsonoutput}
    
</aura:component>

CalloutComponentController.js

({
	MakeCallOut : function(component, event, helper) {
		
        debugger;
        var action=component.get('c.getCalloutResponseContents');
        
      // action.setParams({
        //    "URL":'https://th-apex-http-callout.herokuapp.com/animals'
        //});
        
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            
          console.log('state ='+state);
            if (component.isValid() && state === "SUCCESS") {
               component.set("v.response", response.getReturnValue());
                console.log('v.response='+v.response);
             }
        });
 
        $A.enqueueAction(action);
    },
})

thanks
sheila​​​​​​​
I am trying to understand the basic concept of Aura.Action in lightning but stuck with an error.
ChildComp.cmp

<aura:component >
    
    <aura:attribute name="childTitle"
                    access="global"
                    default="Default Child Title"
                    type="string"/>
    
    <aura:attribute name="onParentClick"
                    type="Aura.Action"/>
    <lightning:layout>
    
    <lightning:layoutItem>
          <div class="header-column">
                    <p class="field-title" title="Child Title Is">Child Title</p>
                    <p>{!v.childTitle}</p>
                </div>
                <div>
                  <lightning:input type="text"
                                   label="Enter some value..."
                                   aura:id="inputChildTitle"
                                   disabled="true"/>
                    
                </div>
        <lightning:button label="Change My Title"
                          onclick="{!c.ChangeTitle}"/>
        
        <!-- Create a button here -->
             <lightning:button label="Enable Child TextBox"
                               onclick="{!v.onParentClick}"/>
        </lightning:layoutItem>
    </lightning:layout>
    
	
</aura:component>

ChildCompController.js

({
	ChangeTitle : function(component, event, helper) {
        component.set("v.childTitle","Changed Title From Child Itself");
	}
})


ParentComp.cmp

<aura:component >
	
  <aura:attribute name="parentTitle"
                    access="global"
                    default="Default Parent Title"
                    type="string"/>
    
     <lightning:layout>
    
    <lightning:layoutItem>
          <div class="header-column">
                    <p class="field-title" title="Parent Title Is">Parent Title</p>
                    <p>{!v.parentTitle}</p>
                </div>
                
         </lightning:layoutItem>
    </lightning:layout>
    
    <c:ChildComp aura:id="childCmp"
                  onParentClick="{!c.EnableTextBox}"/>  
</aura:component>

ParentCompController.js

({
	EnableTextBox : function(component, event, helper) {
		
        debugger;
        //Now find the textbox which is defined in child comp
        var inputChildTitle=component.find("inputChildTitle");
        
        console.log("inputChildTitle="+inputChildTitle);
        
        inputChildTitle.set("v.disabled",false);
	}
})
The error is in the statement  " inputChildTitle.set("v.disabled",false);"

Please help me 

thanks
sheila
 
I have a custom button defined in the page layout of account
when I click this button, enter the account number then it should save back to object
public with sharing class InitiateApprovalController {

    public Account acc{get;set;}
    
    public string accid;
    
    public InitiateApprovalController(ApexPages.StandardController stdcontroller) {

    accid=ApexPages.CurrentPage().getParameters().get('id');
    this.acc=(Account)stdcontroller.getRecord();
    
    acc=[select ID,Name,AccountNumber from Account where ID =:acc.ID];
       
    }
    
    public InitiateApprovalController()
    {
       acc=new Account();
         
    }

    public PageReference customsave()
    {
        try{
        system.debug('acc before update ='+acc);
            
        database.Upsert(acc);
        PageReference pr=new PageReference('/'+acc.Id);

        return pr;
        }
        catch( Exception e ){
            ApexPages.addMessages(e);
            return Null;
        }       
    }
    
}

<apex:page standardController="Account"
            extensions="InitiateApprovalController">
  
  <apex:form >
  
  <apex:pageBlock mode="edit">
            <apex:pageBlockSection title="Approvers" 
                                   id="ApproversId">
                                   
             <apex:inputField Id="name" 
                              html-placeholder="Account Name.." 
                              value="{!Account.Name}" />

             <apex:inputField Id="accnumber" 
                              html-placeholder="Account Number.." 
                              value="{!Account.AccountNumber}" />
                                 
            </apex:pageBlockSection>
            
    <apex:pageBlockButtons location="bottom" html-align="right">
    
    <apex:commandButton id="customsave1"
                        value="save"
                        action="{!customsave}"/>
                        
    </apex:pageBlockButtons>
    
     </apex:pageBlock>
  </apex:form>
    
</apex:page>
I am surprised because I am using Database.Upsert but still it is not saving to object

Can any one please let me know?

Thanks
sheila
 
I am using google crome browser and performing inline editing on lightning datatable.

I am able to display the field values but when I edit Opportunity Name and click save its not saving.

Please let me know the issue.
 
public class DataTableController {

    @AuraEnabled
    public static List<Opportunity> getOpportunities()
    {
        List<Opportunity> oppList=new List<Opportunity>();
        
        oppList=[select Name,Account.Name,StageName,CloseDate,Amount from Opportunity
                 where Amount != NULL];
        
        return oppList;
    }
    
    @AuraEnabled
    public static void updateOpportunities(List<Opportunity> oppsList){
        try
        {
            Database.update(oppsList);
            
          }
        catch(Exception ex)
        {
            system.debug(ex.getMessage());
        }
    }
}

<aura:component implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" 
                controller="DataTableController"
                access="global">
	
        <!-- Three important parts of datatable is Key , data and columns
         so we need attribute for data and columns(metatadata)-->
    <!-- attributes -->
    <aura:attribute name="data" 
                    type="Object"/>
    
    <aura:attribute name="columns" 
                    type="List"/>
    
<aura:attribute name="updatedRecord" type="Object[]" />

    <!-- handlers-->
    <aura:handler name="init" 
                  value="{!this}" 
                  action="{!c.doInit}"/>
    
    <lightning:card title="OpportunityDatatable">
        
        <lightning:datatable aura:id="opportunitydatatable"
                             keyField="id"
                             data="{!v.data}"
                             columns="{!v.columns}"
                             onsave="{!c.handleSaveOpps}"
                             hideCheckboxColumn="true"/>
        
</lightning:card>
    
    {!updatedRecord}

</aura:component>

({
	doInit : function(component, event, helper) {
        
        helper.queryColumns(component,event,helper);
        
        helper.queryContacts(component,event,helper);
  	},
    
    handleSaveOpps: function (component, event, helper) {
        debugger;    
        var draftValues = event.getParam('draftValues');
console.log(draftValues);
        var action = component.get('c.updateOpportunities');
        action.setParams({ 
            "oppsList": draftValues
        });
        action.setCallback(this, $A.getCallback(function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                helper.fireSuccessToast(component);  
                helper.fireRefreshEvt(component);
            } else if (state === "ERROR") {
                var errors = response.getError();
                console.error(errors);
                helper.fireFailureToast(component);  
            }
        }));
        $A.enqueueAction(action);
    }
     
})


({
	queryColumns : function(component,event,helper) {
        
		  component.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', editable : 'true', type: 'text'},
            {label: 'Acc Name', fieldName: 'AccountName', type: 'text'},
            {label: 'StageName', fieldName: 'StageName', type: 'text'},
            {label: 'CloseDate', fieldName: 'CloseDate', type: 'date'},
            {label: 'Amount', fieldName: 'Amount', type: 'currency', cellAttributes: { alignment: 'left' }} 
        ]);
	},
    
    queryContacts : function(component,event,helper) {
        
        var action=component.get('c.getOpportunities');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                
                  //the following code will display the parent account name
                 var rows = response.getReturnValue();
                 for (var i = 0; i < rows.length; i++) {
                    var row = rows[i];
                    if (row.Account) row.AccountName = row.Account.Name;
                }
                //component.set("v.data", response.getReturnValue());
                 component.set("v.data", rows);
            }
        });
        $A.enqueueAction(action);
    },
    
     fireSuccessToast : function(component) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({ 
            'title' : 'Success', 
            'message' : 'Opportunities updated sucessfully.' ,
            'type':'success'
        }); 
        toastEvent.fire(); 
    },
    
    fireFailureToast : function(component) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({ 
            'title' : 'Failed', 
            'message' : 'An error occurred. Please contact your administrator.',
            'type':'error'
        }); 
        toastEvent.fire(); 
    },
    
    fireRefreshEvt : function(component) {
        var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    }
       
})

 
I just started working on lightning datatable.

The code is working but StageName , closedate and amount values are not displayed.
 
public class DataTableController {

    @AuraEnabled
    public static List<Opportunity> getOpportunities()
    {
        List<Opportunity> oppList=new List<Opportunity>();
        
        oppList=[select name,Account.Name,StageName,CloseDate,Amount from Opportunity
                       where StageName != NULL
                       AND
                       Amount != NULL
                       order by Account.Name];
        
        return oppList;
    }
}

<aura:component implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" 
                controller="DataTableController"
                access="global">
	
        <!-- Three important parts of datatable is Key , data and columns
         so we need attribute for data and columns(metatadata)-->
    <!-- attributes -->
    <aura:attribute name="data" 
                    type="Object"/>
    
    <aura:attribute name="columns" 
                    type="List[]"/>
    

    <!-- handlers-->
    <aura:handler name="init" 
                  value="{!this}" 
                  action="{!c.doInit}"/>
    
    <!-- the container element determine the height of the datatable -->
    <div style="height: 300px">
        
        <lightning:datatable aura:id="opportunitydatatable"
                             
                             keyField="id"
                             data="{!v.data}"
                             columns="{!v.columns}"
                             hideCheckboxColumn="true"/>
        
    </div>
</aura:component>

({
	doInit : function(component, event, helper) {
        
        helper.queryColumns(component,event,helper);
        
        helper.queryContacts(component,event,helper);
  	}
})

({
	queryColumns : function(component,event,helper) {
        
		  component.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', type: 'text'},
            {label: 'Acc Name', fieldName: 'Name', type: 'text'},
            {label: 'StageName', fieldName: 'Stage Name', type: 'text'},
            {label: 'CloseDate', fieldName: 'CloseDate', type: 'text'},
            {label: 'Amount', fieldName: 'Amount', type: 'decimal'}  
        ]);
	},
    
    queryContacts : function(component,event,helper) {
        
        var action=component.get('c.getOpportunities');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.data", response.getReturnValue());
                
            }
        });
        $A.enqueueAction(action);
    }
       
})
I need to know two things
a. what is the issue I am facing and how to resolve it
b. How many columns in total can we display in datatable

sheila
 
I am tring to get the basic right for working on force:recorddata
I want to load the record when I click any opportunity record in lightning but no record values are showing up.
<aura:component implements="flexipage:availableForAllPageTypes,
                            force:lightningQuickAction,
                            force:hasRecordId"
                             access="global">
	
    <!--define the object ion which u want to perform the operations-->
    <aura:attribute name="oppor"
                    type="Opportunity"/>

     <aura:attribute name="recordId" type="String"/>

    <aura:attribute name="recordError" 
                    type="String" 
	                description="An error message bound to force:recordData"/>
        
    <aura:attribute name="opporRecord" 
                    type="Opportunity" 
	                description="A simplified view record object to be displayed"/>

       

    <force:recordData aura:id="forceRecordCmp"
                      recordId="{!v.recordId}"
                      targetRecord="{!v.oppor}"
                      targetFields="{!v.opporRecord}"
                      targetError="{!v.recordError}" 
                      recordUpdated="{!c.handleRecordUpdated}"
                      fields="ID,Name,StageName,Amount"/>
    
    <div class="slds-box">
    <div class="slds-text-heading_medium">
            Load Opportunity - Data Service
        </div>
        
          <div class="slds-form--stacked slds-tile">
            <div class="slds-form-element">
                <label class="slds-form-element__label"  >Name: </label>
                <div class="slds-form-element__control">
                  <ui:outputText class="slds-input" 
                    value="{!v.opporRecord.Name}" />
                </div>
            </div> 
            <div class="slds-form-element">
                <label class="slds-form-element__label" >Stage name : </label>
                <div class="slds-form-element__control">
                  <ui:outputTextArea class="slds-input"  
                    value="{!v.opporRecord.StageName}"  />
                </div>
            </div> 
              
               <div class="slds-form-element">
                <label class="slds-form-element__label" >Amount : </label>
                <div class="slds-form-element__control">
                  <ui:outputTextArea class="slds-input"  
                    value="{!v.opporRecord.Amount}"  />
                </div>
            </div> 
              
              
        </div> 
    </div>
</aura:component>

I created a new action and added the button to the page layout of opportunity object.
Now when I click any opportuntity record then I just a poup appears but I don't see any values of the selected record.

please correct me if I am doing wrong.

thanks
sheila
 
I am displaying a list of account record with a checkbox
so when the user checks a record then I need the ID of that selected record in controller for further processing.

I am using actionsupport for this but I am unable to get the ID of the selected record in controller.

Please let me know where I am going wrong and if there is a better way of doing this.
 
public class ActionSupportParamDemoController
{

    public Id targetAccountId;
    
    public Id selectedAccountId { get; set; }
    
    public ActionSupportParamDemoController(ApexPages.StandardController controller) {

    }

  public List<Account> getAccounts()
  {
    return [select ID,Name,Active__c
            from Account
            order By name
            LIMIT 10];
  }

  public PageReference handleCheckBoxChange()
  {
      system.debug('target accountid ='+targetAccountId);
      
      selectedAccountId = targetAccountId;
      
       system.debug('target accountid ='+targetAccountId);
       system.debug('selected account ID ='+selectedAccountId);
      return null;
         
  }
  
  //own method
  public Id getTargetAccountId() {
        return targetAccountId;
    }
  
  public void setTargetAccountId(Id value) {
        targetAccountId = value;
    }
}

visualforce page
<apex:page standardController="Account"
           extensions="ActionSupportParamDemoController">
         
<apex:form>

 <apex:repeat value="{!Accounts}"
                var="accn">
                
       <apex:inputCheckbox value="{!accn.Active__c}">
       <br/>
       <apex:actionSupport event="onchange"
                           action="{!handleCheckBoxChange}">
                           
                    <apex:param id="account" 
                                name="accnId" 
                                value="{!accn.ID}"
                                assignTo="{!targetAccountId}"/>
                            
       </apex:actionSupport>
       
       </apex:inputCheckbox>
       {!accn.Name}
                 
 </apex:repeat>
 {!selectedAccountId}
</apex:form>


</apex:page>

thanks
sheila
 
I need to know how to lock and unlock a record in sfdc

Please let me know frrom real time perspective what other different techniques in what scenarios it will work.

which is the best preferred?

sheila
 
Hi
I am testing my visualforce & apex coding skills .
I have implemented a extension class with standard controller to mimic the functionality of SAVE , SAVE&NEW and QUICKSAVE.
public with sharing class MimicSaveQuickSave {

    ApexPages.StandardController sController;
    
    public MimicSaveQuickSave(ApexPages.StandardController stdcontroller) {

         sController=stdcontroller;
         
    }

    public PageReference saveAndNew()
   {
   
      sController.save();
      PageReference pref=new PageReference('/003/o');
      pref.setRedirect(true);
      
      return pref;
   }
 }
<apex:page standardController="Contact" extensions="MimicSaveQuickSave">
  <apex:form >
  
    <apex:pageBlock title="My Content" mode="edit">
    
      <apex:pageBlockButtons >
      
        <apex:commandButton action="{!save}" 
                            value="Save"/>
                            
      <apex:commandButton action="{!QuickSave}" 
                            value="QuickSave"/> 

       <apex:commandButton action="{!saveAndNew}" 
                            value="SaveAndNew"/>
                            
       <apex:commandButton action="{!cancel}" 
                            value="cancel"/>

      </apex:pageBlockButtons>
      
      <apex:pageBlockSection title="My Content Section" columns="2">
        <apex:inputField value="{!contact.firstname}"/>
        <apex:inputField value="{!contact.lastname}"/>
       </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>
The SAVE &  SAVE&NEW is working but I am unable to code for QUICKSAVE
a) when I click SAVE&NEW button is it possible to redirect to the same visualforce page, so the enduser can enter the input values again.
b) how to implement QUICKSAVE functionality

Pls help me out

Thanks
sheila

 
I have account and contact , In owd contact by default is Controlled By parent.

so as per the concept the access is detemined by parent.

Now account  owd = public readonly is it possible to set owd for contact=private, if possible then if acocunt has multiple contacts then if user share
account record will the contacts be automatically shared

Please correct if my uderstanding is wrong.

Please elaborate where ever required.

sheila
I have a parent visualforce page which has 4 fields  approver_1 , approver_2 , approver_3 and approver_4 which is lookup to user.

I have added a custom button called "InitiateApprovalProcess" in the standard layout of the page
When I click this button it opens as a popup(visualforce page), I have shown the code below where I will enter the field values.
This popup (visualforce page) has save and cancel buttons.

When I click save button it saves the values to the parent, I mean the parent page should get refreshed with the values from the popup.

vf page:
=======
<apex:page standardController="MedConnect__FDA_3500A_MedWatch_Report__c" extensions="VY_InitiateApprovalProcess_Controller" lightningStylesheets="true">
<apex:includeScript value="{!$Resource.MedConnect__jquery}" />
    <apex:includeScript value="{!URLFOR($Resource.MedConnect__jquery_ui,'jquery-ui-1.10.3/ui/minified/jquery-ui.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.MedConnect__jquery_ui,'jquery-ui-1.10.3/themes/base/jquery-ui.css')}"/>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Approvers" id="ApproversId">
    <apex:inputField Id="appId1" html-placeholder="Search People..." value="{!Approver.VY_Approver1__c}" />
    <apex:inputField Id="appId2" html-placeholder="Search People..." value="{!Approver.VY_Approver2__c}" />
    </apex:pageBlockSection>
    <apex:pageBlockSection >
    <apex:inputField Id="appId3" html-placeholder="Search People..." value="{!Approver.VY_Approver3__c}" />
    <apex:inputField Id="appId4" html-placeholder="Search People..." value="{!Approver.VY_Approver4__c}" />
    </apex:pageBlockSection>
    <apex:pageBlockButtons location="bottom" html-align="right">
    <button class="btn" onclick="window.open('/{!$CurrentPage.parameters.id}', target='_self');return false;">Cancel</button>
     <apex:commandButton action="{!customSave}" value="Save" onClick="Window.Close()" onomplete="window.top.location.reload()"/>
     
    </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
    <script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.ID}";
      self.close();
  }
</script>
</apex:page>

apex controller of poup page
======================
public with sharing class VY_InitiateApprovalProcess_Controller
{
    public id ReportIds;
    public MedConnect__FDA_3500A_MedWatch_Report__c Approver { get; set; }
   
    public VY_InitiateApprovalProcess_Controller(ApexPages.StandardController controller) {
        ReportIds = ApexPages.CurrentPage().getParameters().get('id');
        this.Approver = (MedConnect__FDA_3500A_MedWatch_Report__c)controller.getRecord();
        Approver =[SELECT Id,VY_Approver1__c,VY_Approver2__c,VY_Approver3__c,VY_Approver4__c
                            FROM
                            MedConnect__FDA_3500A_MedWatch_Report__c WHERE Id =:ReportIds];
    }
    public VY_InitiateApprovalProcess_Controller()
    {
        Approver = new MedConnect__FDA_3500A_MedWatch_Report__c();
    }
   
    public PageReference customSave()
    {
        PageReference pr;
        try{
            database.upsert(Approver);
            //closeWindow = true;
            pr = new PageReference('/'+Approver.Id );
        }catch( Exception e ){
            ApexPages.addMessages(e);
        }
        return Null;       
    }}

I require 2 functionalities as follows

a) when user click save the popup page should close and the parent page should be refreshed with the updated field values.

b) when I click cancel button the page should close.

Please help me out with this functionality with working code, I am not very good in javascript.

Thanks
sheila


c)
 
My requirement is
a]  to add a custom field say warranty__c in Products object, then show that in opportunity line items while creating a new opportunity.
b] then I will convert the opporutnity line items to quote ine items but I think custom field is not converted.

I added a custom field warranty__c to Product Object but I am not able to see this field while creating line items in opportunity.
Please let me know.

thanks
sheila.

 
I have a custom setting called BindValues__c which has a single field say value__c
It contains values as : A1  1   , A2  2   , A3  3  ,  A4  4 , A5  5 , A6  6 , A7 7 , A8  8 , A9  9 , A10  10 , A11  11

I have worked on a code which binds the values into a picklist as shown below , also I attached a screen shot to show my requirement.

custom setting
values

data
public class CodeGeneratorController {
    public List<SelectOption> Values { get; set; }
    
    public CodeGeneratorController() {
        getValues();
    }
    
    public void getValues() {
        Values = new List<SelectOption>();
        
        List<BindVaues__c> allValues = new List<BindVaues__c>();

        allValues=[SELECT  Name FROM BindVaues__c];
        
        for( BindVaues__c val : allValues) {
          Values.add( new SelectOption( val.Id, val.Name) );
        }
    }
}
<apex:page controller="CodeGeneratorController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:outputLabel value="Values :"/>
                  
                <apex:selectList size="1">
                    <apex:selectOptions value="{!Values}"/>
                </apex:selectList>
             </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
My requirement is I need to access values from 1 to 5 , then do some processing , then values from 6 to 11 then do some other logic.

so I need to split the custom setting values into 2 parts i. 1 to  5 and   6  to 11.
I hope I am clear.
Please let me know how I can proceed further.

Thanks
sheila
 
I have 10000 records  in contact object and 5000 of them are duplicate contact lastname.

My requirement is to eliminate the duplicates lastnames in contact object.

I have soql script which unfortunately doesnt work.

List<Contact> conList=[select ID,LastName from contact LIMIT 50000];   
Map<String,contact> conMap=new Map<String,Contact>();

for(Contact c:conList)
{
   conMap.put(c.LastName,c);
}

//at this point the map should merge the duplicates.  Please correct my understanding

Now datbase.update(conMap.values());

But once update statement is executed, the duplicate records still exists. Only the map has the updated records.

Please let me know if this approach is right....

thanks
sheila




 
Please let me know a specific scenatio where process Builder A calls process Builder B.
and how to schedule process Builder only on the completion of process Builder A


thanks
sheila 
I created a simple process builder to update contact assistant phone with the acocunt phone whenever a new acocunt record gets created.

My requirement is
a] can we write a test class for the same ? if possible can we cover positive and negative test cases.

b] How to debug process builder if error occurs; where to check for the error.

thanks
sheila
I have a list of opportunities inside a list as follows

List<Opportunities> opporList= new List<Opportunities>([select ID,Name,Amount from Opportuntities)];

Now I have the following : Map<ID,Account> accMap=new Map<ID,Account>();

Now I wanto to seggregate accountID and productiD from the list.
I have 2 custom objects i.e objOppor and ObjProduct

ObjProduct is a lookup to objOpportunity.

I need to implement as shown below using datamodel in salesforce.

product          Mandatory fields in objOpportunity
ProductA       date
                      Price

ProductB      Name
                     Qty

ProductC     complain
                    status
               
For every poduct there are certian fields mandatory in the parent object objOppor.

so when I create new record of objOpportunity object and select ProductA from Lookup then I need to enter data into the fields Name and Qty only

similarly if I create record of objOpportunity and select productB from lookup, so in objOpportunity , only the fields Name and Qty should appear and they should ne mandatory.

May I know how to achieve this inside the salesforce datamodel only?

sheila
My understanding of application event is if two components not related to each then we can use applicaiton event to pass data.

Please correct me if wrong.

I have done a code but I am unable to pass data.
ApplicationEvent.vt

<aura:event type="APPLICATION" description="Event template">

<aura:attribute name="message"
                type="string"
                access="public"/>
    
</aura:event>


ParentComponent.cmp

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
	
    <aura:attribute name="someattr"
                    type="string"
                    default="I am GOD"
                    access="private"/>
    
    <aura:registerEvent name="handleApplicationEvent"
                        type="c.ApplicationEvent"/>
    
    <lightning:button name="clickMe"
                      label="ClickMe"
                      onclick="{!c.HandleApplicationEvent}"/>
    
    
</aura:component>


PrentComponentController.js

({
	HandleApplicationEvent : function(component, event, helper) {
		
        debugger;
        var applnEvent=$A.get("e.c:ApplicationEvent");
        
        
        var val=component.get("v.someattr");
        console.log(val);
        
        applnEvent.setParams({"message" : val});
        
        applnEvent.fire();
     }
})


ChildComponent.cmp

<aura:component >
	
    <aura:attribute name="receivedvaluefromparent"
                    type="string"
                    access="private"/>
    
    <aura:handler event="c:ApplicationEvent"
                  action="{!c.HandleApplicationEvent}"/>
    
    <c:ParentComponent/>
    Inside the child component : {!v.receivedvaluefromparent}
    
</aura:component>


ChildComponent.js

({
	HandelApplicationEvent : function(component, event, helper) {
		
        debugger;
        var evtMessage=event.getParam("message");
        
        console.log(evtMessage);
        component.set("v.receivedvaluefromparent",evtMessage.ToString());
        
	}
})


MainApp.app

<aura:application >
    <c:ParentComponent/>
</aura:application>

I checked using debugger but value is not comoing into the child attribute from the parent.

Please let me know where I go wrong.

thanks
sheila S
 
I am using google crome browser and performing inline editing on lightning datatable.

I am able to display the field values but when I edit Opportunity Name and click save its not saving.

Please let me know the issue.
 
public class DataTableController {

    @AuraEnabled
    public static List<Opportunity> getOpportunities()
    {
        List<Opportunity> oppList=new List<Opportunity>();
        
        oppList=[select Name,Account.Name,StageName,CloseDate,Amount from Opportunity
                 where Amount != NULL];
        
        return oppList;
    }
    
    @AuraEnabled
    public static void updateOpportunities(List<Opportunity> oppsList){
        try
        {
            Database.update(oppsList);
            
          }
        catch(Exception ex)
        {
            system.debug(ex.getMessage());
        }
    }
}

<aura:component implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" 
                controller="DataTableController"
                access="global">
	
        <!-- Three important parts of datatable is Key , data and columns
         so we need attribute for data and columns(metatadata)-->
    <!-- attributes -->
    <aura:attribute name="data" 
                    type="Object"/>
    
    <aura:attribute name="columns" 
                    type="List"/>
    
<aura:attribute name="updatedRecord" type="Object[]" />

    <!-- handlers-->
    <aura:handler name="init" 
                  value="{!this}" 
                  action="{!c.doInit}"/>
    
    <lightning:card title="OpportunityDatatable">
        
        <lightning:datatable aura:id="opportunitydatatable"
                             keyField="id"
                             data="{!v.data}"
                             columns="{!v.columns}"
                             onsave="{!c.handleSaveOpps}"
                             hideCheckboxColumn="true"/>
        
</lightning:card>
    
    {!updatedRecord}

</aura:component>

({
	doInit : function(component, event, helper) {
        
        helper.queryColumns(component,event,helper);
        
        helper.queryContacts(component,event,helper);
  	},
    
    handleSaveOpps: function (component, event, helper) {
        debugger;    
        var draftValues = event.getParam('draftValues');
console.log(draftValues);
        var action = component.get('c.updateOpportunities');
        action.setParams({ 
            "oppsList": draftValues
        });
        action.setCallback(this, $A.getCallback(function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                helper.fireSuccessToast(component);  
                helper.fireRefreshEvt(component);
            } else if (state === "ERROR") {
                var errors = response.getError();
                console.error(errors);
                helper.fireFailureToast(component);  
            }
        }));
        $A.enqueueAction(action);
    }
     
})


({
	queryColumns : function(component,event,helper) {
        
		  component.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', editable : 'true', type: 'text'},
            {label: 'Acc Name', fieldName: 'AccountName', type: 'text'},
            {label: 'StageName', fieldName: 'StageName', type: 'text'},
            {label: 'CloseDate', fieldName: 'CloseDate', type: 'date'},
            {label: 'Amount', fieldName: 'Amount', type: 'currency', cellAttributes: { alignment: 'left' }} 
        ]);
	},
    
    queryContacts : function(component,event,helper) {
        
        var action=component.get('c.getOpportunities');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                
                  //the following code will display the parent account name
                 var rows = response.getReturnValue();
                 for (var i = 0; i < rows.length; i++) {
                    var row = rows[i];
                    if (row.Account) row.AccountName = row.Account.Name;
                }
                //component.set("v.data", response.getReturnValue());
                 component.set("v.data", rows);
            }
        });
        $A.enqueueAction(action);
    },
    
     fireSuccessToast : function(component) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({ 
            'title' : 'Success', 
            'message' : 'Opportunities updated sucessfully.' ,
            'type':'success'
        }); 
        toastEvent.fire(); 
    },
    
    fireFailureToast : function(component) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({ 
            'title' : 'Failed', 
            'message' : 'An error occurred. Please contact your administrator.',
            'type':'error'
        }); 
        toastEvent.fire(); 
    },
    
    fireRefreshEvt : function(component) {
        var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    }
       
})

 
I am tring to get my basics clear while making an api call from lightning application.

But when I debug the statement  var action=resposne.getState(), the state is ERROR
 
public class httpCalloutController {

    @AuraEnabled
    public static void getCalloutResponseContents()
    {
        Http h = new Http();
      
        HttpRequest req = new HttpRequest();
		req.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
		req.setMethod('GET');      
        
        // Send the request, and return a response
		HttpResponse res = h.send(req);
		System.debug('response:--> ' + res.getBody());
        
        
        string jsonstring=(string)JSON.deserializeUntyped(res.getBody());
        system.debug('jsonstring-->' + jsonstring);
     }
}

CalloutComponent.cmp

<aura:component implements="flexipage:availableForAllPageTypes" 
                access="global"
                controller="httpCalloutController">
    
    <aura:attribute name="response" type="string"/>
    
	<aura:attribute name="jsonoutput" type="String[]"/>
    
    <lightning:button label="Make Callout" 
                      title="Make Callout"
                      onclick="{!c.MakeCallOut}"/>

    {!jsonoutput}
    
</aura:component>

CalloutComponentController.js

({
	MakeCallOut : function(component, event, helper) {
		
        debugger;
        var action=component.get('c.getCalloutResponseContents');
        
      // action.setParams({
        //    "URL":'https://th-apex-http-callout.herokuapp.com/animals'
        //});
        
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            
          console.log('state ='+state);
            if (component.isValid() && state === "SUCCESS") {
               component.set("v.response", response.getReturnValue());
                console.log('v.response='+v.response);
             }
        });
 
        $A.enqueueAction(action);
    },
})

thanks
sheila​​​​​​​
I have a custom button defined in the page layout of account
when I click this button, enter the account number then it should save back to object
public with sharing class InitiateApprovalController {

    public Account acc{get;set;}
    
    public string accid;
    
    public InitiateApprovalController(ApexPages.StandardController stdcontroller) {

    accid=ApexPages.CurrentPage().getParameters().get('id');
    this.acc=(Account)stdcontroller.getRecord();
    
    acc=[select ID,Name,AccountNumber from Account where ID =:acc.ID];
       
    }
    
    public InitiateApprovalController()
    {
       acc=new Account();
         
    }

    public PageReference customsave()
    {
        try{
        system.debug('acc before update ='+acc);
            
        database.Upsert(acc);
        PageReference pr=new PageReference('/'+acc.Id);

        return pr;
        }
        catch( Exception e ){
            ApexPages.addMessages(e);
            return Null;
        }       
    }
    
}

<apex:page standardController="Account"
            extensions="InitiateApprovalController">
  
  <apex:form >
  
  <apex:pageBlock mode="edit">
            <apex:pageBlockSection title="Approvers" 
                                   id="ApproversId">
                                   
             <apex:inputField Id="name" 
                              html-placeholder="Account Name.." 
                              value="{!Account.Name}" />

             <apex:inputField Id="accnumber" 
                              html-placeholder="Account Number.." 
                              value="{!Account.AccountNumber}" />
                                 
            </apex:pageBlockSection>
            
    <apex:pageBlockButtons location="bottom" html-align="right">
    
    <apex:commandButton id="customsave1"
                        value="save"
                        action="{!customsave}"/>
                        
    </apex:pageBlockButtons>
    
     </apex:pageBlock>
  </apex:form>
    
</apex:page>
I am surprised because I am using Database.Upsert but still it is not saving to object

Can any one please let me know?

Thanks
sheila
 
I am using google crome browser and performing inline editing on lightning datatable.

I am able to display the field values but when I edit Opportunity Name and click save its not saving.

Please let me know the issue.
 
public class DataTableController {

    @AuraEnabled
    public static List<Opportunity> getOpportunities()
    {
        List<Opportunity> oppList=new List<Opportunity>();
        
        oppList=[select Name,Account.Name,StageName,CloseDate,Amount from Opportunity
                 where Amount != NULL];
        
        return oppList;
    }
    
    @AuraEnabled
    public static void updateOpportunities(List<Opportunity> oppsList){
        try
        {
            Database.update(oppsList);
            
          }
        catch(Exception ex)
        {
            system.debug(ex.getMessage());
        }
    }
}

<aura:component implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" 
                controller="DataTableController"
                access="global">
	
        <!-- Three important parts of datatable is Key , data and columns
         so we need attribute for data and columns(metatadata)-->
    <!-- attributes -->
    <aura:attribute name="data" 
                    type="Object"/>
    
    <aura:attribute name="columns" 
                    type="List"/>
    
<aura:attribute name="updatedRecord" type="Object[]" />

    <!-- handlers-->
    <aura:handler name="init" 
                  value="{!this}" 
                  action="{!c.doInit}"/>
    
    <lightning:card title="OpportunityDatatable">
        
        <lightning:datatable aura:id="opportunitydatatable"
                             keyField="id"
                             data="{!v.data}"
                             columns="{!v.columns}"
                             onsave="{!c.handleSaveOpps}"
                             hideCheckboxColumn="true"/>
        
</lightning:card>
    
    {!updatedRecord}

</aura:component>

({
	doInit : function(component, event, helper) {
        
        helper.queryColumns(component,event,helper);
        
        helper.queryContacts(component,event,helper);
  	},
    
    handleSaveOpps: function (component, event, helper) {
        debugger;    
        var draftValues = event.getParam('draftValues');
console.log(draftValues);
        var action = component.get('c.updateOpportunities');
        action.setParams({ 
            "oppsList": draftValues
        });
        action.setCallback(this, $A.getCallback(function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                helper.fireSuccessToast(component);  
                helper.fireRefreshEvt(component);
            } else if (state === "ERROR") {
                var errors = response.getError();
                console.error(errors);
                helper.fireFailureToast(component);  
            }
        }));
        $A.enqueueAction(action);
    }
     
})


({
	queryColumns : function(component,event,helper) {
        
		  component.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', editable : 'true', type: 'text'},
            {label: 'Acc Name', fieldName: 'AccountName', type: 'text'},
            {label: 'StageName', fieldName: 'StageName', type: 'text'},
            {label: 'CloseDate', fieldName: 'CloseDate', type: 'date'},
            {label: 'Amount', fieldName: 'Amount', type: 'currency', cellAttributes: { alignment: 'left' }} 
        ]);
	},
    
    queryContacts : function(component,event,helper) {
        
        var action=component.get('c.getOpportunities');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                
                  //the following code will display the parent account name
                 var rows = response.getReturnValue();
                 for (var i = 0; i < rows.length; i++) {
                    var row = rows[i];
                    if (row.Account) row.AccountName = row.Account.Name;
                }
                //component.set("v.data", response.getReturnValue());
                 component.set("v.data", rows);
            }
        });
        $A.enqueueAction(action);
    },
    
     fireSuccessToast : function(component) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({ 
            'title' : 'Success', 
            'message' : 'Opportunities updated sucessfully.' ,
            'type':'success'
        }); 
        toastEvent.fire(); 
    },
    
    fireFailureToast : function(component) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({ 
            'title' : 'Failed', 
            'message' : 'An error occurred. Please contact your administrator.',
            'type':'error'
        }); 
        toastEvent.fire(); 
    },
    
    fireRefreshEvt : function(component) {
        var refreshEvent = $A.get("e.force:refreshView");
        if(refreshEvent){
            refreshEvent.fire();
        }
    }
       
})

 
I just started working on lightning datatable.

The code is working but StageName , closedate and amount values are not displayed.
 
public class DataTableController {

    @AuraEnabled
    public static List<Opportunity> getOpportunities()
    {
        List<Opportunity> oppList=new List<Opportunity>();
        
        oppList=[select name,Account.Name,StageName,CloseDate,Amount from Opportunity
                       where StageName != NULL
                       AND
                       Amount != NULL
                       order by Account.Name];
        
        return oppList;
    }
}

<aura:component implements="force:appHostable,force:hasRecordId,flexipage:availableForAllPageTypes" 
                controller="DataTableController"
                access="global">
	
        <!-- Three important parts of datatable is Key , data and columns
         so we need attribute for data and columns(metatadata)-->
    <!-- attributes -->
    <aura:attribute name="data" 
                    type="Object"/>
    
    <aura:attribute name="columns" 
                    type="List[]"/>
    

    <!-- handlers-->
    <aura:handler name="init" 
                  value="{!this}" 
                  action="{!c.doInit}"/>
    
    <!-- the container element determine the height of the datatable -->
    <div style="height: 300px">
        
        <lightning:datatable aura:id="opportunitydatatable"
                             
                             keyField="id"
                             data="{!v.data}"
                             columns="{!v.columns}"
                             hideCheckboxColumn="true"/>
        
    </div>
</aura:component>

({
	doInit : function(component, event, helper) {
        
        helper.queryColumns(component,event,helper);
        
        helper.queryContacts(component,event,helper);
  	}
})

({
	queryColumns : function(component,event,helper) {
        
		  component.set('v.columns', [
            {label: 'Opp Name', fieldName: 'Name', type: 'text'},
            {label: 'Acc Name', fieldName: 'Name', type: 'text'},
            {label: 'StageName', fieldName: 'Stage Name', type: 'text'},
            {label: 'CloseDate', fieldName: 'CloseDate', type: 'text'},
            {label: 'Amount', fieldName: 'Amount', type: 'decimal'}  
        ]);
	},
    
    queryContacts : function(component,event,helper) {
        
        var action=component.get('c.getOpportunities');
        
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.data", response.getReturnValue());
                
            }
        });
        $A.enqueueAction(action);
    }
       
})
I need to know two things
a. what is the issue I am facing and how to resolve it
b. How many columns in total can we display in datatable

sheila
 
I am tring to get the basic right for working on force:recorddata
I want to load the record when I click any opportunity record in lightning but no record values are showing up.
<aura:component implements="flexipage:availableForAllPageTypes,
                            force:lightningQuickAction,
                            force:hasRecordId"
                             access="global">
	
    <!--define the object ion which u want to perform the operations-->
    <aura:attribute name="oppor"
                    type="Opportunity"/>

     <aura:attribute name="recordId" type="String"/>

    <aura:attribute name="recordError" 
                    type="String" 
	                description="An error message bound to force:recordData"/>
        
    <aura:attribute name="opporRecord" 
                    type="Opportunity" 
	                description="A simplified view record object to be displayed"/>

       

    <force:recordData aura:id="forceRecordCmp"
                      recordId="{!v.recordId}"
                      targetRecord="{!v.oppor}"
                      targetFields="{!v.opporRecord}"
                      targetError="{!v.recordError}" 
                      recordUpdated="{!c.handleRecordUpdated}"
                      fields="ID,Name,StageName,Amount"/>
    
    <div class="slds-box">
    <div class="slds-text-heading_medium">
            Load Opportunity - Data Service
        </div>
        
          <div class="slds-form--stacked slds-tile">
            <div class="slds-form-element">
                <label class="slds-form-element__label"  >Name: </label>
                <div class="slds-form-element__control">
                  <ui:outputText class="slds-input" 
                    value="{!v.opporRecord.Name}" />
                </div>
            </div> 
            <div class="slds-form-element">
                <label class="slds-form-element__label" >Stage name : </label>
                <div class="slds-form-element__control">
                  <ui:outputTextArea class="slds-input"  
                    value="{!v.opporRecord.StageName}"  />
                </div>
            </div> 
              
               <div class="slds-form-element">
                <label class="slds-form-element__label" >Amount : </label>
                <div class="slds-form-element__control">
                  <ui:outputTextArea class="slds-input"  
                    value="{!v.opporRecord.Amount}"  />
                </div>
            </div> 
              
              
        </div> 
    </div>
</aura:component>

I created a new action and added the button to the page layout of opportunity object.
Now when I click any opportuntity record then I just a poup appears but I don't see any values of the selected record.

please correct me if I am doing wrong.

thanks
sheila
 
I am displaying a list of account record with a checkbox
so when the user checks a record then I need the ID of that selected record in controller for further processing.

I am using actionsupport for this but I am unable to get the ID of the selected record in controller.

Please let me know where I am going wrong and if there is a better way of doing this.
 
public class ActionSupportParamDemoController
{

    public Id targetAccountId;
    
    public Id selectedAccountId { get; set; }
    
    public ActionSupportParamDemoController(ApexPages.StandardController controller) {

    }

  public List<Account> getAccounts()
  {
    return [select ID,Name,Active__c
            from Account
            order By name
            LIMIT 10];
  }

  public PageReference handleCheckBoxChange()
  {
      system.debug('target accountid ='+targetAccountId);
      
      selectedAccountId = targetAccountId;
      
       system.debug('target accountid ='+targetAccountId);
       system.debug('selected account ID ='+selectedAccountId);
      return null;
         
  }
  
  //own method
  public Id getTargetAccountId() {
        return targetAccountId;
    }
  
  public void setTargetAccountId(Id value) {
        targetAccountId = value;
    }
}

visualforce page
<apex:page standardController="Account"
           extensions="ActionSupportParamDemoController">
         
<apex:form>

 <apex:repeat value="{!Accounts}"
                var="accn">
                
       <apex:inputCheckbox value="{!accn.Active__c}">
       <br/>
       <apex:actionSupport event="onchange"
                           action="{!handleCheckBoxChange}">
                           
                    <apex:param id="account" 
                                name="accnId" 
                                value="{!accn.ID}"
                                assignTo="{!targetAccountId}"/>
                            
       </apex:actionSupport>
       
       </apex:inputCheckbox>
       {!accn.Name}
                 
 </apex:repeat>
 {!selectedAccountId}
</apex:form>


</apex:page>

thanks
sheila
 
Hi
I am testing my visualforce & apex coding skills .
I have implemented a extension class with standard controller to mimic the functionality of SAVE , SAVE&NEW and QUICKSAVE.
public with sharing class MimicSaveQuickSave {

    ApexPages.StandardController sController;
    
    public MimicSaveQuickSave(ApexPages.StandardController stdcontroller) {

         sController=stdcontroller;
         
    }

    public PageReference saveAndNew()
   {
   
      sController.save();
      PageReference pref=new PageReference('/003/o');
      pref.setRedirect(true);
      
      return pref;
   }
 }
<apex:page standardController="Contact" extensions="MimicSaveQuickSave">
  <apex:form >
  
    <apex:pageBlock title="My Content" mode="edit">
    
      <apex:pageBlockButtons >
      
        <apex:commandButton action="{!save}" 
                            value="Save"/>
                            
      <apex:commandButton action="{!QuickSave}" 
                            value="QuickSave"/> 

       <apex:commandButton action="{!saveAndNew}" 
                            value="SaveAndNew"/>
                            
       <apex:commandButton action="{!cancel}" 
                            value="cancel"/>

      </apex:pageBlockButtons>
      
      <apex:pageBlockSection title="My Content Section" columns="2">
        <apex:inputField value="{!contact.firstname}"/>
        <apex:inputField value="{!contact.lastname}"/>
       </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>
The SAVE &  SAVE&NEW is working but I am unable to code for QUICKSAVE
a) when I click SAVE&NEW button is it possible to redirect to the same visualforce page, so the enduser can enter the input values again.
b) how to implement QUICKSAVE functionality

Pls help me out

Thanks
sheila

 
I have a parent visualforce page which has 4 fields  approver_1 , approver_2 , approver_3 and approver_4 which is lookup to user.

I have added a custom button called "InitiateApprovalProcess" in the standard layout of the page
When I click this button it opens as a popup(visualforce page), I have shown the code below where I will enter the field values.
This popup (visualforce page) has save and cancel buttons.

When I click save button it saves the values to the parent, I mean the parent page should get refreshed with the values from the popup.

vf page:
=======
<apex:page standardController="MedConnect__FDA_3500A_MedWatch_Report__c" extensions="VY_InitiateApprovalProcess_Controller" lightningStylesheets="true">
<apex:includeScript value="{!$Resource.MedConnect__jquery}" />
    <apex:includeScript value="{!URLFOR($Resource.MedConnect__jquery_ui,'jquery-ui-1.10.3/ui/minified/jquery-ui.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.MedConnect__jquery_ui,'jquery-ui-1.10.3/themes/base/jquery-ui.css')}"/>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Approvers" id="ApproversId">
    <apex:inputField Id="appId1" html-placeholder="Search People..." value="{!Approver.VY_Approver1__c}" />
    <apex:inputField Id="appId2" html-placeholder="Search People..." value="{!Approver.VY_Approver2__c}" />
    </apex:pageBlockSection>
    <apex:pageBlockSection >
    <apex:inputField Id="appId3" html-placeholder="Search People..." value="{!Approver.VY_Approver3__c}" />
    <apex:inputField Id="appId4" html-placeholder="Search People..." value="{!Approver.VY_Approver4__c}" />
    </apex:pageBlockSection>
    <apex:pageBlockButtons location="bottom" html-align="right">
    <button class="btn" onclick="window.open('/{!$CurrentPage.parameters.id}', target='_self');return false;">Cancel</button>
     <apex:commandButton action="{!customSave}" value="Save" onClick="Window.Close()" onomplete="window.top.location.reload()"/>
     
    </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
    <script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.ID}";
      self.close();
  }
</script>
</apex:page>

apex controller of poup page
======================
public with sharing class VY_InitiateApprovalProcess_Controller
{
    public id ReportIds;
    public MedConnect__FDA_3500A_MedWatch_Report__c Approver { get; set; }
   
    public VY_InitiateApprovalProcess_Controller(ApexPages.StandardController controller) {
        ReportIds = ApexPages.CurrentPage().getParameters().get('id');
        this.Approver = (MedConnect__FDA_3500A_MedWatch_Report__c)controller.getRecord();
        Approver =[SELECT Id,VY_Approver1__c,VY_Approver2__c,VY_Approver3__c,VY_Approver4__c
                            FROM
                            MedConnect__FDA_3500A_MedWatch_Report__c WHERE Id =:ReportIds];
    }
    public VY_InitiateApprovalProcess_Controller()
    {
        Approver = new MedConnect__FDA_3500A_MedWatch_Report__c();
    }
   
    public PageReference customSave()
    {
        PageReference pr;
        try{
            database.upsert(Approver);
            //closeWindow = true;
            pr = new PageReference('/'+Approver.Id );
        }catch( Exception e ){
            ApexPages.addMessages(e);
        }
        return Null;       
    }}

I require 2 functionalities as follows

a) when user click save the popup page should close and the parent page should be refreshed with the updated field values.

b) when I click cancel button the page should close.

Please help me out with this functionality with working code, I am not very good in javascript.

Thanks
sheila


c)
 
I have a custom setting called BindValues__c which has a single field say value__c
It contains values as : A1  1   , A2  2   , A3  3  ,  A4  4 , A5  5 , A6  6 , A7 7 , A8  8 , A9  9 , A10  10 , A11  11

I have worked on a code which binds the values into a picklist as shown below , also I attached a screen shot to show my requirement.

custom setting
values

data
public class CodeGeneratorController {
    public List<SelectOption> Values { get; set; }
    
    public CodeGeneratorController() {
        getValues();
    }
    
    public void getValues() {
        Values = new List<SelectOption>();
        
        List<BindVaues__c> allValues = new List<BindVaues__c>();

        allValues=[SELECT  Name FROM BindVaues__c];
        
        for( BindVaues__c val : allValues) {
          Values.add( new SelectOption( val.Id, val.Name) );
        }
    }
}
<apex:page controller="CodeGeneratorController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:outputLabel value="Values :"/>
                  
                <apex:selectList size="1">
                    <apex:selectOptions value="{!Values}"/>
                </apex:selectList>
             </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
My requirement is I need to access values from 1 to 5 , then do some processing , then values from 6 to 11 then do some other logic.

so I need to split the custom setting values into 2 parts i. 1 to  5 and   6  to 11.
I hope I am clear.
Please let me know how I can proceed further.

Thanks
sheila
 
My understanding of application event is if two components not related to each then we can use applicaiton event to pass data.

Please correct me if wrong.

I have done a code but I am unable to pass data.
ApplicationEvent.vt

<aura:event type="APPLICATION" description="Event template">

<aura:attribute name="message"
                type="string"
                access="public"/>
    
</aura:event>


ParentComponent.cmp

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
	
    <aura:attribute name="someattr"
                    type="string"
                    default="I am GOD"
                    access="private"/>
    
    <aura:registerEvent name="handleApplicationEvent"
                        type="c.ApplicationEvent"/>
    
    <lightning:button name="clickMe"
                      label="ClickMe"
                      onclick="{!c.HandleApplicationEvent}"/>
    
    
</aura:component>


PrentComponentController.js

({
	HandleApplicationEvent : function(component, event, helper) {
		
        debugger;
        var applnEvent=$A.get("e.c:ApplicationEvent");
        
        
        var val=component.get("v.someattr");
        console.log(val);
        
        applnEvent.setParams({"message" : val});
        
        applnEvent.fire();
     }
})


ChildComponent.cmp

<aura:component >
	
    <aura:attribute name="receivedvaluefromparent"
                    type="string"
                    access="private"/>
    
    <aura:handler event="c:ApplicationEvent"
                  action="{!c.HandleApplicationEvent}"/>
    
    <c:ParentComponent/>
    Inside the child component : {!v.receivedvaluefromparent}
    
</aura:component>


ChildComponent.js

({
	HandelApplicationEvent : function(component, event, helper) {
		
        debugger;
        var evtMessage=event.getParam("message");
        
        console.log(evtMessage);
        component.set("v.receivedvaluefromparent",evtMessage.ToString());
        
	}
})


MainApp.app

<aura:application >
    <c:ParentComponent/>
</aura:application>

I checked using debugger but value is not comoing into the child attribute from the parent.

Please let me know where I go wrong.

thanks
sheila S
 
I am working on @Future methods and quueueable apex.

we can monitor queueable job from apex jobs, get JOB ID and check the status of queueable apex job using the object AsynApexJob from workbench.

a] My question is can we do all of the above for a method marked with @future?

b] can we use database.stateful with queueable apex?

c] can we schedule a queueable job by specifying a cron string ?

c]  what is flexipage queue and how does it work..

Please elaborate in details and I request forum memebers to be specific.

thanks
sheila