• Priyanka S 27
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 9
    Replies
Hi
I have university as parent object & college as child object.
There is a master-detail relationship defined on child object i.e college

I have a parent-child soql as follows
List<University__c> univList=[select Name,(select Name from colleges__r) from university__c];
system.debug(univList);

Also I have a child-parent soql as follows
List<college__c> univList=[select Name,university__r.Name from college__c
system.debug(univList);

when I execute the parent-child query I do not get any child related records .
Also when I execute child-parent query I do get the name of the college but the university ID I get but I want the university name also not the ID

please let me know.

Thanks
pooja
 
Can anyone please tell me how to do One to One Relationship?
Hi All,

Please help me to write details page navigation, once contact recod is inserted.

Component:
<aura:component controller="contactRegistrationController">
    <aura:attribute name="contacts" type="Contact[]"/>
     
<aura:attribute name="newContact" type="Contact"
     default="{ 'sobjectType': 'Contact',
                      'FirstName': '',
                    'LastName': '',
                    'Email': '',
                    'Phone': '','MailingStreet':'','MailingCity':'','MailingState':'','Zip':'','MailingCountry':'',
                    'Password__c': '' }"/>
    
    <!-- PAGE HEADER -->
    <div class="slds-page-header" role="banner">
      <div class="slds-grid">
        <div class="slds-col">
          <p class="slds-text-heading--label">Contact</p>
          <h1 class="slds-text-heading--medium">My Contact</h1>
        </div>
      </div>
    </div>
    <!-- / PAGE HEADER -->

    <!-- NEW EXPENSE FORM -->
    <div class="slds-col slds-col--padded slds-p-top--large">

  <div aria-labelledby="newcontactform">

  <!-- BOXED AREA -->
  <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="newexpenseform" class="slds-text-heading--small 
      slds-p-vertical--medium">
      Add Contact
    </legend>

    <!-- CREATE NEW EXPENSE FORM -->
    <form class="slds-form--stacked">
        <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="fstname" label="First Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.FirstName}"
                  required="true"/>
          </div></div>
      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="lstname" label="Last Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.LastName}"
                  required="true"/>
          </div>
     </div>
    
         <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="email" label="Email"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.Email}"
                  required="true"/>
          </div>
     </div>
    <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="phone" label="Phone"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.Phone}"
                  required=""/>
          </div></div>
    <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="maillingstr" label="Mailing Street"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.MailingStreet}"
                  required=""/>
          </div>
   </div>
        <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="mailingcity" label="Mailing City"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.MailingCity}"
                  required=""/>
          </div>
   </div>
        <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="mailingstate" label="Mailing State"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.MailingState}"
                  required=""/>
          </div>
   </div>
        <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="mailingzip" label="Mailing Zip"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.Zip}"
                  required=""/>
          </div>
   </div>
        <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="mailingcountry" label="Mailing Country"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.MailingCountry}"
                  required=""/>
          </div>
   </div>
    <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="pwd" label="Password"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newContact.Password__c}"
                  required=""/>
          </div>
   </div>
      
      <div class="slds-form-element">
          <ui:button label="Submit"
              class="slds-button slds-button--brand"
              press="{!c.clickCreateContact}"/>
      </div>
    </form>
    <!-- / CREATE NEW EXPENSE FORM -->

  </fieldset>
  <!-- / BOXED AREA -->

</div>
<!-- / CREATE NEW EXPENSE -->

    </div>
    <!-- / NEW EXPENSE FORM -->
</aura:component>

Client side controller:
({
    clickCreateContact: function(component, event, helper) {
        console.log('inside click create contact');

        // Simplistic error checking
        var validExpense = true;

        // Name must not be blank
        var firstnameField = component.find("fstname");
        var frtname = firstnameField.get("v.value");
        
        if ($A.util.isEmpty(frtname)){
            validExpense = false;
            firstnameField.set("v.errors", [{message:"First name can't be blank."}]);
        }
        else {
            firstnameField.set("v.errors", null);
        }
        
        var lastnameField = component.find("lstname");
        var larname = lastnameField.get("v.value");
        if ($A.util.isEmpty(larname)){
            validExpense = false;
            lastnameField.set("v.errors", [{message:"Last Name can't be blank."}]);
        }
        else {
            // If the amount looks good, unset any errors...
            lastnameField.set("v.errors", null);
        }
        var emailField = component.find("email");
        var emailid = emailField.get("v.value");
        if ($A.util.isEmpty(emailid)){
            validExpense = false;
            emailField.set("v.errors", [{message:"Email can't be blank."}]);
        }
        else {
            // If the amount looks good, unset any errors...
            emailField.set("v.errors", null);
        }
        
        var phoneField = component.find("phone");
        var phone = phoneField.get("v.value");
        if ($A.util.isEmpty(phone)){
            validExpense = false;
            phoneField.set("v.errors", [{message:"Phone can't be blank."}]);
        }
        else {
            // If the amount looks good, unset any errors...
            phoneField.set("v.errors", null);
        }
        
        var pwdField = component.find("pwd");
        var password = pwdField.get("v.value");
        if ($A.util.isEmpty(password)){
            validExpense = false;
            pwdField.set("v.errors", [{message:"Password can't be blank."}]);
        }
        else {
            // If the amount looks good, unset any errors...
            pwdField.set("v.errors", null);
        }
        // ... hint: more error checking here ...

        // If we pass error checking, do some real work
       if(validExpense){
            // Create the new expense
            var newContact = component.get("v.newContact");
            var newAccount = component.get("v.newAccount");
                //component.find("fstname").get("v.value");

            var newRecNamevar=component.find("fstname").get("v.value");
            console.log("Create Contact: " + JSON.stringify(newContact));

            helper.createContact(component, newContact);
            //alert('New record created successfully!!'+newRecNamevar);
             //alert('New Contact ' +newRecNamevar+ ' created successfully!!');
       }
    },
})

Helper:
({
    createContact: function(component, contact) {
        console.log('inside helper');
        
    var action = component.get("c.saveContact");
        console.log('after method called ');
    action.setParams({
        "Contact": contact
        //component.get("v.contacts")
         
    });
    action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var contacts = component.get("v.contacts");
            contacts.push(response.getReturnValue());
            component.set("v.contacts", contacts);
            alert('wooow child contact with parent account insert successfully');
 
        }
    });
    $A.enqueueAction(action);
},
    
})

Controller:
public with sharing class contactRegistrationController {
     
    @AuraEnabled
    public static Contact saveContact(Contact Contact) {
        account acc=new account();
        acc.Name=contact.FirstName +' ' +contact.LastName;
        insert acc;
        system.debug('inside controller method');
        // Perform isUpdatable() checking first, then
        Contact.AccountId=acc.Id;
        upsert Contact;
        return Contact;
    }
}

Regards,
Shaik
  • September 29, 2016
  • Like
  • 0
I have a visualforce page that has a picklist field "QAD Domain". This is the coding to display the field

<apex:pageBlockSectionItem >
                 <apex:outputLabel value="QAD Domain"/>
                 <apex:inputField id="QADDomain" value="{!ord.account.QAD_Domain__c}">
                       <apex:actionSupport event="onchange" rendered="false">                             
                              <apex:param name=" {!domain} " value="{!ord.account.QAD_Domain__c}" assignTo="{!domain}"/> 
                       </apex:actionSupport>
                 </apex:inputField>
           </apex:pageBlockSectionItem>   



I have a controller that does the get and set method. When I run the debug log I see there is no value that is passed to the controller for the domain. Can someone point me what correction I need to make to the code in order to get the selected value in the controller.

public String  domain {get;set;}
if(domain != null)
                  mainSoql = mainSoql + ' and  Order_Product__r.order.account.QAD_Domain__c = \''+ domain + '\'';

String mainSoql = 'select id,'+
                    'Name,'+
                   'Start_Date__c,'+
                    'End_Date__c,'+
                    'Order_Product__r.UnitPrice,'+            
                    'Order_Product__r.id,'+
                    'Order_Product__r.order.account.QAD_Domain__c,'+
                    'Order_Product__r.order.accountid,'+
                    'Invoice__r.Orders__r.Name'+
                    ' from Invoice_Line_Items__c where Invoice__r.Status__c= \''+
                    invoiceStatus+'\' and  Unit_Price__c > 0';

 
Hi all, 

Some tests are failing on my production org with error "Too many SOQL queries" but the tests passed on my sandbox which is a week behind from the prod site. So I started by looking at a particular test to find out where the problem lies by printing out the 'Queries Used' at different steps on the apex test code on both prod and sandbox. Interestingly I found out that an additional trigger was running on the production site which I am still trying to figure out why. The log has has something like:

11:10:37.169 (6359606075)|CODE_UNIT_FINISHED|Workflow:01IG0000002KhwC
11:10:37.169 (6361377923)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:ParentFieldUpdate
11:10:37.169 (6361471398)|CODE_UNIT_FINISHED|Workflow:ParentFieldUpdate

I am thinking maybe the problem might be here but cannot find a Workflow with 'ParentFieldUpdate'. Does anyone know what this could be?

Here are logs from both Prod and sandbox:

Production site:
11:10:07.496 (6909806810)|WF_FLOW_ACTION_BEGIN|09LG0000000PCDO
11:10:07.911 (6911029804)|FLOW_CREATE_INTERVIEW_BEGIN|00D170000000PkK|300G00000004rE5|301G0000000L7a7
11:10:07.911 (6911063628)|FLOW_CREATE_INTERVIEW_END|60139cd58510b6d5bf552215d318157529ae4ce-36f2|Dispatch Changing Original Date Rejected or Approved
11:10:07.912 (6912430672)|FLOW_START_INTERVIEWS_BEGIN|1
11:10:07.912 (6912482534)|FLOW_START_INTERVIEW_BEGIN|60139cd58510b6d5bf552215d318157529ae4ce-36f2|Dispatch Changing Original Date Rejected or Approved
11:10:07.912 (6918343468)|FLOW_START_INTERVIEW_END|60139cd58510b6d5bf552215d318157529ae4ce-36f2|Dispatch Changing Original Date Rejected or Approved
11:10:07.912 (6918354094)|FLOW_START_INTERVIEWS_END|1
11:10:07.496 (6919402559)|WF_FLOW_ACTION_END|09LG0000000PCDO
11:10:07.496 (6919433785)|WF_FLOW_ACTION_BEGIN|09LG0000000L0gi
11:10:07.921 (6921194785)|FLOW_CREATE_INTERVIEW_BEGIN|00D170000000PkK|300G00000004rGf|301G0000000PSvD
11:10:07.921 (6921236499)|FLOW_CREATE_INTERVIEW_END|60149cd58510b6d5bf552215d318157529ae4ce-36f1|Dispatch Currency Update
11:10:07.937 (6937772081)|FLOW_START_INTERVIEWS_BEGIN|1
11:10:07.937 (6937808252)|FLOW_START_INTERVIEW_BEGIN|60149cd58510b6d5bf552215d318157529ae4ce-36f1|Dispatch Currency Update
11:10:07.937 (6943548977)|FLOW_START_INTERVIEW_END|60149cd58510b6d5bf552215d318157529ae4ce-36f1|Dispatch Currency Update
11:10:07.937 (6943565494)|FLOW_START_INTERVIEWS_END|1
11:10:07.496 (6945020472)|WF_FLOW_ACTION_END|09LG0000000L0gi
11:10:07.496 (6945063573)|WF_TIME_TRIGGERS_BEGIN
11:10:07.496 (6958320240)|WF_ACTIONS_END| Field Update: 4; Flow Trigger: 11;
11:10:07.496 (6958337061)|CODE_UNIT_FINISHED|Workflow:01IG0000002KhwC
11:10:07.496 (6961000790)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:ParentFieldUpdate
11:10:07.496 (6961075944)|CODE_UNIT_FINISHED|Workflow:ParentFieldUpdate
11:10:07.496 (6964374035)|CODE_UNIT_STARTED|[EXTERNAL]|01qG0000000ipuf|AccountInformation on Charter trigger event BeforeUpdate for [a0r1700000Ax2xv]
11:10:07.496 (6978114250)|CODE_UNIT_FINISHED|AccountInformation on Charter trigger event BeforeUpdate for [a0r1700000Ax2xv]

Sandbox Log:
 
11:10:37.169 (6329081903)|WF_FLOW_ACTION_BEGIN|09LG0000000PCDO
11:10:37.330 (6330127573)|FLOW_CREATE_INTERVIEW_BEGIN|00D5B0000008dN8|300G00000004rE5|301G0000000L7a7
11:10:37.330 (6330173276)|FLOW_CREATE_INTERVIEW_END|6801c8b955c758d717542ec848f215752990e82-26e7|Dispatch Changing Original Date Rejected or Approved
11:10:37.331 (6331284858)|FLOW_START_INTERVIEWS_BEGIN|1
11:10:37.331 (6331309489)|FLOW_START_INTERVIEW_BEGIN|6801c8b955c758d717542ec848f215752990e82-26e7|Dispatch Changing Original Date Rejected or Approved
11:10:37.331 (6337066765)|FLOW_START_INTERVIEW_END|6801c8b955c758d717542ec848f215752990e82-26e7|Dispatch Changing Original Date Rejected or Approved
11:10:37.331 (6337076824)|FLOW_START_INTERVIEWS_END|1
11:10:37.169 (6337700220)|WF_FLOW_ACTION_END|09LG0000000PCDO
11:10:37.169 (6337729438)|WF_FLOW_ACTION_BEGIN|09LG0000000L0gi
11:10:37.338 (6338676531)|FLOW_CREATE_INTERVIEW_BEGIN|00D5B0000008dN8|300G00000004rGf|301G0000000PSvD
11:10:37.338 (6338722496)|FLOW_CREATE_INTERVIEW_END|6802c8b955c758d717542ec848f215752990e82-26e6|Dispatch Currency Update
11:10:37.339 (6339831759)|FLOW_START_INTERVIEWS_BEGIN|1
11:10:37.339 (6339856397)|FLOW_START_INTERVIEW_BEGIN|6802c8b955c758d717542ec848f215752990e82-26e6|Dispatch Currency Update
11:10:37.339 (6345584914)|FLOW_START_INTERVIEW_END|6802c8b955c758d717542ec848f215752990e82-26e6|Dispatch Currency Update
11:10:37.339 (6345594699)|FLOW_START_INTERVIEWS_END|1
11:10:37.169 (6346176796)|WF_FLOW_ACTION_END|09LG0000000L0gi
11:10:37.169 (6346220593)|WF_TIME_TRIGGERS_BEGIN
11:10:37.169 (6359597915)|WF_ACTIONS_END| Field Update: 4; Flow Trigger: 11;
11:10:37.169 (6359606075)|CODE_UNIT_FINISHED|Workflow:01IG0000002KhwC
11:10:37.169 (6361377923)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:ParentFieldUpdate
11:10:37.169 (6361471398)|CODE_UNIT_FINISHED|Workflow:ParentFieldUpdate
11:10:37.169 (6363663867)|USER_DEBUG|[57]|DEBUG|-UpdateRelatedDispatch Queries4: 50

Here you can notice on the list line that additional trigger spawns whereas on the sandbox it does not run.
 
Hi all,

We've used the open source chart.js to implement our charts in lightning components but we've noticed that if the chart's data set changes, e.g. a picklist that the user can select a different value from which generates a different data set for the chart, the chart flickers between the old & new values when the mouse moves over it.
Looking around the web the solution from Chart.js is to keep a global variable in the javascript which holds the chart object when it is created & then destroy that chart object before re-creating a new one (see http://stackoverflow.com/questions/28609932/chartjs-resizing-very-quickly-flickering-on-mouseover). However I don't think that mechanism is possible from within a lightning component, but I may be wrong. Any suggestions?

Here's a working example of the problem. After the chart is displayed if you check the checkbox, new data will appear in the chart.  If you then move the mouse over the chart it will toggle between the old & new chart at certain positions. Obviously in real component I'd be calling an apex controller etc. but I thought a simplified version would be easier to understand.  For it to work you'll need to create a static resource called Chart that contains the Chart.js from http://www.chartjs.org/

(AndeeChart.cmp)
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
<ltng:require scripts="{!$Resource.Chart}" afterScriptsLoaded="{!c.init}"/>

<aura:attribute name="dataset" type="String" default="1"  description="Which set of data to display in the chart.  Will be either 1 or 2"/>

<div class="slds-grid slds-wrap">
    <div class="slds-col slds-size--1-of-1 slds-small-size--1-of-2 slds-medium-size--1-of-4">
        <ui:inputCheckbox label="Toggle Data?" click="{!c.updateDataset}"/>

    </div>
    <div class="slds-col slds-size--1-of-1 slds-small-size--1-of-2 slds-medium-size--3-of-4">
        Chart1<br></br>
        <canvas aura:id="andeeChart" id="andeeChart123"/>
    </div>

</div>
(AndeeChartController.js)
({
    init : function(component, event, helper) {
        helper.setupChart(component);
    },
    updateDataset : function(component, event, helper) {
        var dataset = component.get('v.dataset');
        if (dataset == '1'){
            dataset = '2';
        } else {
            dataset = '1';
        }
        component.set('v.dataset', dataset)
        helper.setupChart(component);
    } 
})

(AndeeChartHelper.js)
({
    setupChart  : function(component) {


        // Normally call apex controller to get data but hardcoded for demonstration purposes
        var dataset = component.get('v.dataset');
        var data;
        var jsonRetVal
        if (dataset == '1'){
            jsonRetVal = {"chartLabels":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"chartData":[1.00,3.00,6.00,10.00,15.00,21.00]}
        } else {
           jsonRetVal = {"chartLabels":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"chartData":[21.00,3.00,16.00,19.00,17.00,12.00]} 
        }


        var el = component.find('andeeChart').getElement();
        var ctx = el.getContext('2d'); 

        // Need something here to destroy any chart that is currently being displayed to stop the 'flicker'

        new Chart(ctx, {
            type: 'bar',
            data: {
                labels: jsonRetVal.chartLabels,
                datasets: [
                    {
                        label: "Data",
                        fillColor: "rgba(220,220,220,1)",
                        strokeColor: "rgba(220,220,220,1)",                
                        data: jsonRetVal.chartData
                    }
                ]
            },
            options: {
                hover: {
                    mode: "none"
                },
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero:true
                        }
                    }]
                }
            }
        });



    }
})

Thanks in advance for any help you can offer as this is driving me made.
Hi,
I create a lightning component for the lightning experience record pages. In the customize record page, I drag standard Record Detail component and my componont to the page. In my component, I update some fields of a record. After I save those field, I fire up the e.force:refreshView event. But the standard record detail component did not refresh to show the new value of those field. Is there any way to force to refresh the standard record detail component?