• anji punyamanthula
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 7
    Replies
I created Picklist by using Lightning:Select but while i'm editing the record default value is coming not selected one, How to avoid that.
Can u please find attachments and provide some good solution for that.

Thanks in Advance,
Anji.​​​​​​​

User-added imageUser-added image
Component-Markup:
<div class="slds-form-element__control">
<div class="uiInput uiInputDate uiInput--default uiInput--input uiInput--datetime">
             <label class="label inputLabel uiLabel-left form-element__label uiLabel">
              <span class="">{!v.customField.musqotmpm__startdate__c.Label}</span>
              <span class="required ">*</span>
      <aura:if isTrue="{!!empty(v.customField.musqotmpm__startdate__c.InlineHelpText)}">
     <lightning:helptext content="{!v.customField.musqotmpm__startdate__c.InlineHelpText}" />
         </aura:if>
           </label>
<lightning:input aura:id="date-StartDate" type="date" name="" label="" class="ltng-label-hide" value="{!v.sObject.Musqotmpm__StartDate__c}"                                                                                                                                                                                onchange="{!c.handlePeriod}" />
                                                                                    </div>
                                                                                </div>

Component:Js:
closeModal : function(component, event, helper) {
        component.set("v.hasErrors", false);
         $A.get('e.force:refreshView').fire();
        //$A.get("e.force:closeQuickAction").fire();
        //helper.readCustomField(component, event, helper);
        //document.location.reload(true);
        helper.hideModal(component, event, helper);
        //component.set('v.sObject', {});       
        if(!component.get('v.fromPlan')){
            window.history.back();
        }
},
    User-added image
I want to invoke  update Class of Map in trigger, can any one let me know how to do  I'm attaching my controller below

public class Map_Acc_Con_upp_Ex1 {
    public Static void Afterupdate(Map<Id,Account> accs){
        List<Account> accounts=accs.values();
        Set<Id> acids=accs.keyset();
        List<Contact> contacts=new List<Contact>();
        List<contact> cons=[select LastName,phone,AccountId from Contact where Accountid in:acids];
        for(Contact c:cons){
            c.phone=c.Account.Phone;
            contacts.add(c);
        }
        update contacts;
    }

}
I have 3 users i want to fetch 10 records from Account object and assign first 3 records to first user next 3 records 2nd user another 3 records to 3rd user and again it will go to 1st user to assign another record how to do that can any one help me in that.
my code is below 

batch class:

global class Batch_Example_3 implements Database.Batchable<sobject>,Database.Stateful {
    global Static Integer count;
  global  Database.QueryLocator Start(Database.BatchableContext bc){
        String s='select name,ownerid from Account  limit 10';
        return database.getQueryLocator(s);
                                
 }
    global void execute(Database.BatchableContext bc,List<Account> accs){
        count=0;
        List<User> myuser=[select id from user limit 3];
        
        for(user u:myuser){
           for(Account a:accs){
            a.OwnerId=u.id;
              count+=1;
               update a;
        
        
        }
        
        }
        
        //update accs;
        
    }
    global void finish(Database.BatchableContext bc){
        
    }

}

execution:
Batch_Example_3 ba=new Batch_Example_3();
Id JobId=database.executeBatch(ba,1);

 
public class XML_Example_4 {
    public String result      {set;get;}
    public String parseText {set;get;}
    public void parse(){
        DOM.Document doc=new DOM.Document();
        doc.load(parseText);
        DOM.XMLNode root=doc.getRootElement();
         

        result=root.getName();
        List<DOM.XMLNode> childs= root.getChildElements();
        for(DOM.XMLNode c:childs){
            result=result+'\n'+c.getName()+' :'+c.getText();
                    

            if(c.getNamespace()=='Std'){
                list<DOM.XMLNode> root1=c.getChildren();
            for(DOM.XMLNode c1:root1){    
                result=result+c1.getName()+' :'+c1.getText();
            }
            }
                
            System.debug('result1'+c.getChildren());
        }
        
    }
}

i'm passing this string
<?xml version="1.0" encoding="UTF-8"?><as:name xmlns:as="capital"><lastname>anji</lastname><Firstname>punyamanthula</Firstname><age>24</age><Student name="raju" Age="30" xmlns:std="capital" /></as:name>
I tried below code but i'm not getting o/p
Apex trigger:

trigger Rollup_Acc on Opportunity (After insert,After update,After delete,after undelete) {
    if(trigger.isinsert && trigger.isupdate && trigger.isdelete && trigger.isundelete){
    List<Account> accs=new List<Account>();
    Set<Id> ids=new Set<Id>();
    for(opportunity o:trigger.new){
        ids.add(o.AccountId);
        
    }
    decimal sum;
    for(Account acc :[select id,name,Amount__c,(select id,name,amount from opportunities ) from Account where id =:ids]){
        sum=0;
        for(opportunity op:acc.opportunities){
            sum+=op.Amount;
        }
        acc.AnnualRevenue=sum;
        accs.add(acc);
        
        
    }
   
    update accs;
    }
   
    
}
Below Example after taking Account als its throwing same error where i'm wrong let me know any one help in that 


trigger con_accname_error on Contact (before insert,before update) {
    for(contact c:trigger.new){
        if(c.Account==null){
            c.addError('pl enter account name');
        }
       
        
    }

}

 
Component-Markup:
<div class="slds-form-element__control">
<div class="uiInput uiInputDate uiInput--default uiInput--input uiInput--datetime">
             <label class="label inputLabel uiLabel-left form-element__label uiLabel">
              <span class="">{!v.customField.musqotmpm__startdate__c.Label}</span>
              <span class="required ">*</span>
      <aura:if isTrue="{!!empty(v.customField.musqotmpm__startdate__c.InlineHelpText)}">
     <lightning:helptext content="{!v.customField.musqotmpm__startdate__c.InlineHelpText}" />
         </aura:if>
           </label>
<lightning:input aura:id="date-StartDate" type="date" name="" label="" class="ltng-label-hide" value="{!v.sObject.Musqotmpm__StartDate__c}"                                                                                                                                                                                onchange="{!c.handlePeriod}" />
                                                                                    </div>
                                                                                </div>

Component:Js:
closeModal : function(component, event, helper) {
        component.set("v.hasErrors", false);
         $A.get('e.force:refreshView').fire();
        //$A.get("e.force:closeQuickAction").fire();
        //helper.readCustomField(component, event, helper);
        //document.location.reload(true);
        helper.hideModal(component, event, helper);
        //component.set('v.sObject', {});       
        if(!component.get('v.fromPlan')){
            window.history.back();
        }
},
    User-added image
I tried below code but i'm not getting o/p
Apex trigger:

trigger Rollup_Acc on Opportunity (After insert,After update,After delete,after undelete) {
    if(trigger.isinsert && trigger.isupdate && trigger.isdelete && trigger.isundelete){
    List<Account> accs=new List<Account>();
    Set<Id> ids=new Set<Id>();
    for(opportunity o:trigger.new){
        ids.add(o.AccountId);
        
    }
    decimal sum;
    for(Account acc :[select id,name,Amount__c,(select id,name,amount from opportunities ) from Account where id =:ids]){
        sum=0;
        for(opportunity op:acc.opportunities){
            sum+=op.Amount;
        }
        acc.AnnualRevenue=sum;
        accs.add(acc);
        
        
    }
   
    update accs;
    }
   
    
}
Below Example after taking Account als its throwing same error where i'm wrong let me know any one help in that 


trigger con_accname_error on Contact (before insert,before update) {
    for(contact c:trigger.new){
        if(c.Account==null){
            c.addError('pl enter account name');
        }
       
        
    }

}