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

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 35
    Questions
  • 17
    Replies
I have a json coming from api and it has a datetime as 2019-01-01T00:00:00-05:00 I am displaying this in lightning component as below .

<lightning:formattedDateTime value="{!medicareValues.effectivePeriod.datetimeBegin}" year="numeric" month="numeric" day="numeric"/
                                                                                              
But I want to remove the time and display the date as 2019-01-01. Please let me know how I can achieve this.

thanks
sheila
Hello

I have created a visual flow using the cloud flow designer.
Now inside a I have text as   "Accumulators" which I want to display as an hyperlink.

I want to navigate to an custom tab in my lightning component when I click "Accumalators".

I gave like this " /flow/MyFlow/retURL=url
where url is the path where I would refer to custom tab

But its not working as expected

2. I have text as "Appeal" and I will make this as hyperlink, then when I click Appeal the flow should end.

Please let me know with example how I can achieve my functionality?

thanks
sheila
I have a lightning data service .

I have shown the complete code I have with me.

<aura:attribute name="simpleRecord" type="Object" description="A simplified view record object to be displayed"/>
    <aura:attribute name="recordError" type="String" description="An error message"/>
 <aura:attribute name="record" type="Object" description=""/>

    <force:recordData aura:id="somecaseRecord"
                          recordId="{!v.caseId}"
                          targetError="{!v.recordError}"
                          targetRecord="{!v.record}"
                          targetFields="{!v.simpleRecord}"
                          mode="VIEW"                      
                          fields="Id,Status"/>

I have Status is a field defined in the case object and case Id is generated during the init handler.

I want to fetch the value of the status field in the controller.js

if (component.get("v.simpleRecord.Status") != "Closed")
{
 //then do some logic
}

I tried doing like this also.
if (component.get("v.record").Status  != "Closed")
{
 //then some logic I will do
}

But its not fetching the status field value 

Let me know where I am going wrong.

thanks
sheila S
I have a custom field called status__c in the case object.

This field status__c is a picklist with values like "In-Progress", "Closed" etc.

My requirement is to use a lightning data service to fetch the value of this field in the donit event of my lightning component.

In the doInit event of lightning component I will be doing like this

if (status__c != Closed)
{
    helper.callsomelogic(component,helper)
}

 <aura:attribute name="casememberError" type="String" description="Error In LDS"/>
    <aura:attribute name="casemembership" type="Object" description="Access Record with field Name Status to get the Value"/>
<aura:attribute name="recordId" type="String" description="case RecordID"/>

<force:recordData aura:id="caseRecord"
            recordId="{!v.recordId}"
            fields="Status__c"
            targetRecord="{!v.casemembership}"
            targetFields="{!v.casesimpleMembership}"
            targetError="{!v.casememberError}"/> 

Pleae let me know how I can achieve this. 
Any help is greatly appreciated.

thanks
sheila
I have a piece of code in my lightning component as follows

pCodeShortDesc = pCodeShortDesc.subtring(0,28);

this return a string like "Nebuent    Inh 300 mg"

I want to remove the two extra white spaces in the above.

Please let me know urgent how to do.

thanks
sheila
In my lightning component I am having like this.

<aura:attribute name="claimType"  type="String" default="Pharmacy" description="some pharamcy"/>

I want the default value of the attribute in the controller.js file of the component for further processing.

Please tell me how to do this.

thanks
sheila

 
I am not very good in javascript

I have a lightning component and in the controller.js file I have as shown below

var uos=claimlines.unitofservice;

when I debug this it returns a value of 30.0000

My client has told me to keep only two zeroes after the decimal point,

A working code would be greatly helpful.

thanks
sheila
 
A lightning component makes an api call to an external service and the result is an json response

I have given the json response as follows.
 
{"readClaimResponse": {

   "status":    {

      "statusCode": "0",

      "detail": "SUCCESS"
   },

   "claim":    {

      "claimIdentifier":       {

         "idSource": "63",

         "idValue": "183245438591000",

         "idType": "pharmacyclaims"

      },

      "claimType": "Pharmacy",  

      "billedAmount": "520",

      "allowedAmount": "500.4",

      "planPaidAmount": "400.32",

      "totalMemberResponsibility": "100.08",

      "paidToProvider": "400.32",

      "deductible": "0.00",

      "claimProcessedDate": "2018-11-20T20:51:37.001100",

      "claimStatus": "Final",

      "dateOfServiceBegin": "2018-10-15",

      "dateOfServiceEnd": "2018-10-15",

      "providerName": "CVS PHARMACY 16890",

      "amountCoinsurance": "100.08",

      "amountCopay": "0.00",

      "healthClaimLines": [      {

         "amountCopay": "0.00",

         "amountCoinsurance": "100.08",

         "billedAmount": "520",

         "allowedAmount": "500.4",

         "deductible": "0.00",

         "paidAmount": "400.32",

         "memberResponsibility": "100.08",

         "procedureCode": [         {

            "procedureCode": "63323087715",

            "procedureCodeDescr": "Nebupent     Inh 300mg"

         }],

         "healthClaimLineIdentifier":          {

            "idSource": "100",

            "idValue": "FDGP2KT5800+001",

            "idType": "Healthclaimline"

         },

         "dateOfServiceBegin": "2018-10-15",

         "dateOfServiceEnd": "2018-10-15",

         "unitsOfService": "30.000"

      }]

   }

}}
what I am not understanding is how to get the "claimType" value into an aura:attribute for further processing.
I need the value of "claimType" i.e Pharmacy into an aura:attribute for further processing.
Please let me know how to achieve this at the very earliest.
Like I do not have much exp in json

thanks
sheila
My requirement is to display contact records so for every contact record displayed I need a radio button beside it.

I have done like so far.
@AuraEnabled
    Public static List<Contact> showContacts()
    {
      List<Contact> conList = [select Id,Name
                                 FROM 
                                 contact
                                 Order By name LIMIT 15];
        return conList;
    }

<aura:component implements="flexipage:availableForAllPageTypes" 
                controller="MyController"
                access="global" >
	
    <aura:attribute name="contacts"
                    type="List[]"
                    access="global"/>
    
    <aura:handler name="init"
                  value="{!this}"
                  action="{!c.doInit}"/>
    
    
    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                <th scope="col">
                    <div class="slds-truncate" title="ContactName">Name</div>
                </th>
                
            </tr>
        </thead>
        
        <!--table body start, 
        Iterate contact list as a <tr> 
        -->
        <tbody>
            <aura:iteration items="{!v.contacts}" 
                            var="con">
                <tr>
                    <th scope="row">
                          <ui:inputRadio label="{!v.con}" change="{!c.onRadioChange}" />
                        <div class="slds-truncate" title="{!con.Name}">{!con.Name}</div>
                   </th>
                </tr>
            </aura:iteration>
           
        </tbody>
        
    </table>
    
</aura:component>

({
	doInit : function(component, event, helper) {
        helper.queryContacts(component,event,helper);
		
	},
    
    onRadioChange : function(component, event, helper) {
         // var selected = event.getSource().get("v.con");
        //alert(selected);
      }
})

({
	queryContacts : function(component,event,helper) {
		
        var action=component.get('c.showContacts');
        
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                
                component.set("v.contacts", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);

	}
})

<aura:application extends="force:slds"
                  access="global">
    
    <c:RadioButtons/>
    
</aura:application>
I am able to display radio button for every contact name but I am able to select multiple records.
I need to fire the change event when I select one contact record.

also other than <ui:radiobutton> what other component can we use?
thanks
sheila
 
I am trying to understand how we can put an vf page inside an lightning component and send message from lightning component to vf page.
I am using the website https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html   for reference.

In my current project a similar scenario has been implemented where the vf page embedded inside the lightning component makes an api call.

so I am breaking down things and trying to understand.
sendMessageToVF.cmp

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
	
    <aura:attribute name="message"
                    type="string"
                    default="Hello communication"
                    access="global"/>
    
    <aura:attribute name="vfHost"
                    type="string"
                    default="sheilasrivastav-dev-ed--c.na35.visual.force.com"
                    access="global"/>
    
     <lightning:input type="text" 
                     label="Message" 
                     name="Message"
                     value="{!v.message}"/>
    
    <lightning:button label="sendtoVF"
                      onclick="{!c.sendtoVF}"/>
    
    <!--the visual force page that we need to send data to-->
    <iframe aura:id="vfFrame" 
            src="{!'https://' + v.vfHost + '/apex/myvfpage'}"/>

</aura:component>


SendMessageToVFController.js

({
	sendtoVF : function(component, event, helper) {
		
        debugger;
        var message = component.get("v.message");
        
        console.log('message= '+message);
        var vfOrigin = "https://" + component.get("v.vfHost");
        
        console.log('vfOrigin= '+vfOrigin);
        
        var vfWindow = component.find("vfFrame").getElement().contentWindow;
        
        console.log('vfWindow= '+vfWindow);
        
        vfWindow.postMessage(message, vfOrigin);
	}
})


myvfpage.vfp

<apex:page >
    
    <script>
    var lexOrigin = "https://sheilasrivastav-dev-ed.lightning.force.com";
    window.addEventListener("message", function(event) {
        if (event.origin !== lexOrigin) {
            // Not the expected origin: reject message!
            return;
        }
        // Handle message
        console.log(event.data);
    }, false);
</script>
    
</apex:page>

Mainapp.app

<aura:application extends="force:slds"
                  access="global">
    
    <c:SendMessageToVFPage/>
    
</aura:application>

when I run the application I get an error as follows:

This page has an error. You might just need to refresh it. Action failed: c:SendMessageToVFPage$controller$sendtoVF [Blocked a frame with origin "https://sheilasrivastav-dev-ed.lightning.force.com" from accessing a cross-origin frame.] Failing descriptor: {c:SendMessageToVFPage$controller$sendtoVF}

I think locker service is coming into the picture but how to resolve this.

Pls let me know.

thanks
sheila
 
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 a piece of code in my lightning component as follows

pCodeShortDesc = pCodeShortDesc.subtring(0,28);

this return a string like "Nebuent    Inh 300 mg"

I want to remove the two extra white spaces in the above.

Please let me know urgent how to do.

thanks
sheila
My requirement is to display contact records so for every contact record displayed I need a radio button beside it.

I have done like so far.
@AuraEnabled
    Public static List<Contact> showContacts()
    {
      List<Contact> conList = [select Id,Name
                                 FROM 
                                 contact
                                 Order By name LIMIT 15];
        return conList;
    }

<aura:component implements="flexipage:availableForAllPageTypes" 
                controller="MyController"
                access="global" >
	
    <aura:attribute name="contacts"
                    type="List[]"
                    access="global"/>
    
    <aura:handler name="init"
                  value="{!this}"
                  action="{!c.doInit}"/>
    
    
    <table class="slds-table slds-table--bordered slds-table--cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                <th scope="col">
                    <div class="slds-truncate" title="ContactName">Name</div>
                </th>
                
            </tr>
        </thead>
        
        <!--table body start, 
        Iterate contact list as a <tr> 
        -->
        <tbody>
            <aura:iteration items="{!v.contacts}" 
                            var="con">
                <tr>
                    <th scope="row">
                          <ui:inputRadio label="{!v.con}" change="{!c.onRadioChange}" />
                        <div class="slds-truncate" title="{!con.Name}">{!con.Name}</div>
                   </th>
                </tr>
            </aura:iteration>
           
        </tbody>
        
    </table>
    
</aura:component>

({
	doInit : function(component, event, helper) {
        helper.queryContacts(component,event,helper);
		
	},
    
    onRadioChange : function(component, event, helper) {
         // var selected = event.getSource().get("v.con");
        //alert(selected);
      }
})

({
	queryContacts : function(component,event,helper) {
		
        var action=component.get('c.showContacts');
        
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                
                component.set("v.contacts", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);

	}
})

<aura:application extends="force:slds"
                  access="global">
    
    <c:RadioButtons/>
    
</aura:application>
I am able to display radio button for every contact name but I am able to select multiple records.
I need to fire the change event when I select one contact record.

also other than <ui:radiobutton> what other component can we use?
thanks
sheila
 
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 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 have a piece of code in my lightning component as follows

pCodeShortDesc = pCodeShortDesc.subtring(0,28);

this return a string like "Nebuent    Inh 300 mg"

I want to remove the two extra white spaces in the above.

Please let me know urgent how to do.

thanks
sheila
A lightning component makes an api call to an external service and the result is an json response

I have given the json response as follows.
 
{"readClaimResponse": {

   "status":    {

      "statusCode": "0",

      "detail": "SUCCESS"
   },

   "claim":    {

      "claimIdentifier":       {

         "idSource": "63",

         "idValue": "183245438591000",

         "idType": "pharmacyclaims"

      },

      "claimType": "Pharmacy",  

      "billedAmount": "520",

      "allowedAmount": "500.4",

      "planPaidAmount": "400.32",

      "totalMemberResponsibility": "100.08",

      "paidToProvider": "400.32",

      "deductible": "0.00",

      "claimProcessedDate": "2018-11-20T20:51:37.001100",

      "claimStatus": "Final",

      "dateOfServiceBegin": "2018-10-15",

      "dateOfServiceEnd": "2018-10-15",

      "providerName": "CVS PHARMACY 16890",

      "amountCoinsurance": "100.08",

      "amountCopay": "0.00",

      "healthClaimLines": [      {

         "amountCopay": "0.00",

         "amountCoinsurance": "100.08",

         "billedAmount": "520",

         "allowedAmount": "500.4",

         "deductible": "0.00",

         "paidAmount": "400.32",

         "memberResponsibility": "100.08",

         "procedureCode": [         {

            "procedureCode": "63323087715",

            "procedureCodeDescr": "Nebupent     Inh 300mg"

         }],

         "healthClaimLineIdentifier":          {

            "idSource": "100",

            "idValue": "FDGP2KT5800+001",

            "idType": "Healthclaimline"

         },

         "dateOfServiceBegin": "2018-10-15",

         "dateOfServiceEnd": "2018-10-15",

         "unitsOfService": "30.000"

      }]

   }

}}
what I am not understanding is how to get the "claimType" value into an aura:attribute for further processing.
I need the value of "claimType" i.e Pharmacy into an aura:attribute for further processing.
Please let me know how to achieve this at the very earliest.
Like I do not have much exp in json

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 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