• prasanth kumar
  • NEWBIE
  • 226 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 62
    Questions
  • 48
    Replies
Hi, 

   I am just passing the name of the newly inserting account name to method and this method will create a new record in destination salesforce org(another salesforce org). But it is throwing error message.  Please help.

Error is:  Malformed JSON: Expected '{' at the beginning of object

 
**source ORG code:-**

   

   

     trigger SendAccount on Account(after insert)
    {
    for(Account a : Trigger.new){
       SendAccountFromSource.createAccount(a.Name, a.Id);
    }
    }
    
    
    
    Apex class:- 
    
    
    public class SendAccountFromSource {
     private final String clientId = '3MVG9ZL0ppGP5UrCXwgNBMST50bhCIRR_E_t7gUGb2TLvmA5wQD3YWiAOBnjOr7x5x1L2MB8G4frfx.oZRkOh';
     private final String clientSecret = '8220657863400185678';
     private final String username = 'prasanthkumar@gmail.com';
     private final String password = 'dolly1234';
     
     
     public class deserializeResponse
     {
      public String id;
      public String access_token;
     }
     
     
     
    
    public String ReturnAccessToken (SendAccountFromSource acount)
     {
      String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
      Http h = new Http();
      HttpRequest req = new HttpRequest();
      system.debug('The request body is: ' + reqbody);
      req.setBody(reqbody);
      req.setMethod('GET');
      req.setEndpoint('https://ap2.salesforce.com/services/oauth2/token');
      HttpResponse res = h.send(req);
      deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
      
      system.debug('The resp1.access_token is : ' +resp1.access_token+' The status code is: '+res.getstatuscode() +'....' +res.getstatus());
      
      
      return resp1.access_token;
      
      
     }
     @future(callout=true)
     public static void createAccount(String accName, String accId) 
     {
      SendAccountFromSource acount = new SendAccountFromSource();
      String accessToken = acount.ReturnAccessToken (acount);
     
      if(accessToken != null)
      {
      system.debug('inside the if statement :' );
       String endPoint = 'https://ap2.salesforce.com/services/apexrest/displayAccount/';
       System.debug('Account anme of ='+accname);
                   
                    
            
       Http h2 = new Http();
       HttpRequest req1 = new HttpRequest();
       String rename=accName;
      string rajas = '"'+rename+'"';
       req1.setHeader('Authorization','Bearer ' + accessToken);
       req1.setHeader('Content-Type','application/json');
       req1.setHeader('accept','application/json');
       
      
       req1.setBody('{"name" : rajas }');
       req1.setMethod('POST');
       req1.setEndpoint(endPoint);
       HttpResponse res1 = h2.send(req1);
       
       system.debug('The value of the res1 is :' +res1);
       deserializeResponse resp2 = (deserializeResponse)JSON.deserialize(res1.getbody(),deserializeResponse.class);
      system.debug('The value of resp2 :' +resp2);
       Account a = [SELECT Id FROM Account WHERE Id = :accId];
       a.externalId__c = resp2.id;
       update a;
      }
     }
     }

 
Hi this console.log is not coming. please help.        console.log("inside jaff");.  This statement is inside of the action.setcallback.(in the 2nd function of lighning controller)  Please help.   If i click on the      <ui:button label="insert cont" press="{!c.newcontacts}" />   then 3 console logs are coming but the console.log inside the callback method is not coming.   
 
public class eventsexampleapexclass {
     @AuraEnabled
     public static string getlightcons(contact con)
     {           system.debug('inside the The error message value is : ');

         string errormsg ='hello raja';
      
         return errormsg;
     }
    
}





























({
	myAction : function(component, event, helper) {
        // var for judgment on if statement.
           var ifvalue;
        
        var textval = component.find("name").get("v.value");
        console.log(textval);

        var textval2 = component.find("name2").get("v.value");
        
        if(textval == textval2)
            ifvalue = "true";
       
        console.log('The ifvalue is : '+ ifvalue);
        component.set("v.ifvalue",ifvalue);
	},
    
    newcontacts : function(component, event, helper){
    var contval = component.get("v.newcontact");
        console.log('The con vlaue is ',contval);
        
        var action = component.get("c.getlightcons");
        
        action.setParams({
             con : contval
        });
               console.log('jaff coming');
            console.log("jaff coming22");

        
        action.setCallback(this,function(a){
                        console.log("inside jaff");

        });
    console.log("jaff coming22123");
  }
})























<aura:component controller="eventsexampleapexclass">
  <!--  <aura:handler name="init" value="{!this}" action="{!c.myAction}" /> -->
    <aura:attribute name="ifvalue" type="String" />
    // checking the two inputtext values are same or not. 
    <ui:inputtext label="your name" aura:id="name"  />
    <ui:inputtext label="you name again" aura:id="name2" change="{!c.myAction}" />
    
    .....The value of ifvalue is : {!v.ifvalue} .... <br/><br/>
    
    
    <aura:if isTrue="{!v.ifvalue}">
    True
    <aura:set attribute="else">
      False
    </aura:set>
    </aura:if>   <br/><br/>
    
    <h2>The New contact details</h2>
   
    <aura:attribute name="newcontact" type="contact" default="{ 'sobjectType': 'Contact' }"/>
                 
    <aura:attribute name="errormeg" type="string" />
    
    <h2 style="color:red;">{!errormeg}</h2>
    <ui:inputText aura:id="contactName" 
                 value="{!v.newcontact.Name}" label="Name"/>
   
    <ui:inputPhone value="{!v.newcontact.Phone}" aura:id="contactPhone" label="Phone"/>
    <ui:inputText value="{!v.newcontact.Department}"  aura:id="contactde" label="Department"/>
    <ui:inputDate value="{!v.newcontact.Birthdate}"  aura:id="contactbd" label="D.O.B" displayDatePicker="true"/>
    <ui:inputText value="{!v.newcontact.Level__c}" aura:id="contactll" label="Level"/>
   
    <br/><br/>
    <ui:button label="insert cont" press="{!c.newcontacts}" />

</aura:component>

 
hi,  i am getting    "unexpceted token where  error."      please solve this. 

Date dte = Date.today().addDays(-2);
      
         String Name ='dell ';
       String ActName ='Activity ';
       
return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c staus__c !=\''+Name+'\' and type__c=\''+ActName+'\' where actual_End_date__c =: dte '
        return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c  =: Date.today().addDays(-2)');   

i am using this in batch apex start method.  i am getting error at this line at  where condition.     FATAL_ERROR System.QueryException: unexpected token: 'where'  
rendered condition with if statement not wokring.   I want to show only records which are matching with the account owner emails. 
 
<apex:page controller="inputfieldsexample1" showHeader="false">
<apex:form >

 <apex:variable var="coo" value="{!$User.Email}" />   .......... {!coo}
<apex:pageblock >

<apex:pageblocktable value="{!accs}" var="a">
<apex:column value="{!a.id}"  rendered="{ !If(a.owner.email == 'coo' ,true,false) }" />
<apex:column value="{!a.name}" />
<apex:column value="{!a.industry}" />

<apex:column value="{!a.owner.email}" />


</apex:pageblocktable>


n merge field, like {!$User.Email}..........{!$User.Id}.



</apex:pageblock>
</apex:form>

</apex:page>

controller code:-
 
public class inputfieldsexample1 {


public account acc{set;get;}
public string email1 {set;get;}
public list<account> accs{Set;get;}
public inputfieldsexample1 ()
{
email1='prasanth523001@gmail.com';
accs=[select id,name,industry,owner.email,owner.id from account where name='anmesh' or name='anmesh1' ];
}

}

 
hi,  i am getting this error while saving the code in visualforce page.  This error is caused due to of "{!accts[a].name}"  in VF apge.

Error:-  

Error: /apex/retunrtype: java.lang.NullPointerException
Error: null
<apex:page controller="allaccountslist">
 
 <apex:repeat value="{!accts}" var="a">
 {!a.id}............... {!accts[a].name} <br/><br/>
 </apex:repeat>
 
</apex:page>
 
public class allaccountslist {

public list<sobject> getaccts ()
{
    list<sobject> acc= [select id,name from account limit 20];
    
    return acc;

}}

 

The below is the all code. error is going if i remove this code.   please help me to solve this. 
 
if(! allquoteowners.contains(Owner.Name))
            {
             

					  if(opp1.stagename == 'Won - Delivery' && daysbetween >= 2)
						 {
						   opp1.Quote_Created__c=true;
						   toUpdateopplist.add(opp1);
						 }   
         
             }


 
global class EmailNotifcation implements Schedulable
{
global integer daysbetween; 
    global static String scheduleIt() 
    {     
        //To start job nxt minuted itself
        dateTime dt=System.now().addMinutes(1); 
        String Csec,Cmin,Chr,Cday,Cmonth,CYear;
        Csec=String.valueof(dt.second());
        Cmin=String.valueof(dt.minute());
        string SchTimer = Csec+' '+Cmin+' * * * ?' ; 
        
        EmailNotifcation  emNOt = new EmailNotifcation();
        
        //String SchTimer = '0 1 12 * * ?'; 
        //String SchTimer = '0 1 * * * ?';
        //String SchTimer =   '0 0 2/3 * * ?';    
        return System.schedule('Email Notification', SchTimer,emNOt );                  
    }   

    global void execute(SchedulableContext SC)
    { 
        emailNotificationMethod();
        System.debug('----------in execute methid');
    }

    public void emailNotificationMethod()
    {
    
		
		list<opportunity> toUpdateopplist= new list<opportunity>();
        // procedure for getting all user names in slesforce
       Map<string,string> allusernamesmap= new map<string,string>() ;
        
       for(user u1:[select id,name from user] )
       {
       allusernamesmap.put(u1.id,u1.name);
       }
       
           
      // getting all quote owner names. 
           
        set<string> allquoteowners = new set<String>();
        
        for(quote q1:[SELECT CreatedById FROM Quote])
        {
          //   .add(q1.CreatedById);
            string name1=allusernamesmap.get(q1.CreatedById);
            allquoteowners.add(name1);
        }
        
       //  Prodecure for getting all opportunites records who is  not created the quote 
        
        list<opportunity> updateopps =new list<opportunity>();       
        
        for(opportunity opp1:[Select id, Owner.Name, Quote_Created__c, ClosedOwn_Date__c, stagename,closedate from Opportunity])
         { 
          daysbetween=opp1.closedate.daysBetween(date.today()); 
           
		   if(! allquoteowners.contains(Owner.Name))
            {
             

					  if(opp1.stagename == 'Won - Delivery' && daysbetween >= 2)
						 {
						   opp1.Quote_Created__c=true;
						   toUpdateopplist.add(opp1);
						 }   
         
             } 


		}  
                           
     //   update  toUpdateopplist;
    }
}

 
hi, i am trying to rendered (hide) the pageblocktable which is nested pageblocktable.  


Error: Incorrect parameter type for function 'CONTAINS()'. Expected Text, received Object     in visualforce page rendered
<apex:page CONTROLLER="DYNAMICAPPROVALCLASS">
<apex:form >
<apex:pageblock title="cust with trans">
<apex:pageblocktable value="{!cus}" var="a">
<apex:column value="{!a.id}" />
<apex:column value="{!a.name}" />

<apex:column >  
<apex:pageblocktable value="{!a.transactions__r}" var="t">
<apex:column value="{!t.Amount__c}" />
<apex:column value="{!t.Transaction_Type__c}" />


<apex:column >  
<apex:pageblocktable  rendered="{!IF(CONTAINS(m3,t.id),true,false)}"  value="{!m3[t.id]}" var="p"  >
<apex:column value="{!p.status}"  />
</apex:pageblocktable>
</apex:column>

</apex:pageblocktable>

</apex:column>
</apex:pageblocktable>
</apex:pageblock>


<apex:pageblock title="All Transactions List">
<apex:pageblocktable value="{!trans}" var="a">
<apex:column value="{!a.Amount__c }" />
<apex:column value="{!a.Name }" />
<apex:column value="{!a.Transaction_Type__c}" />
<apex:column >
<apex:repeat value="{!a.processinstances}" var="p">
{!p.status} ................... {!p.SubmittedById}
</apex:repeat>
 </apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>

controller:-
 
public class DYNAMICAPPROVALCLASS {

public list<transaction__c> trans{set;get;}
public list<customer__c> cus{set;get;}
public list<ProcessInstance> p1 {set;get;}
public map<id,list<string>> m1{Set;get;}
public map<id, ProcessInstance> m3{set;get;}
public map<string,account> m2{set;get;}
public  DYNAMICAPPROVALCLASS()
{
account acc=new account(name='tesing 123');
m3=new map<id, ProcessInstance>();
trans=[SELECT Amount__c,Name,Transaction_Type__c,(SELECT Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstances) FROM transaction__c];

cus=[select id,name,(select id, amount__c,name,Transaction_Type__c from transactions__r where name='18') from customer__c];

set<id> ids=new set<id>();
for(customer__c c1:cus)
{
for(transaction__c t1:c1.transactions__r)
{
ids.add(t1.id); } }
// p1=[select id,status,SubmittedById from ProcessInstance where TargetObjectId in:ids];
// m1=new map<id ,list<string>>();
 
 
 
 for(ProcessInstance pp:[select id,status,SubmittedById,TargetObjectId from ProcessInstance where TargetObjectId in:ids])
     {
       m3.put(pp.targetobjectid, pp);  
    
       }
 
}
}

 

hi, loan__c --> Transaction__c -->  customer__c  -->  loan is the grand child, transaction is child, customer is parent.
 
public list<customer__c> cus=[select id,name,(select amount__c,name,Transaction_Type__c,(select id from loans__r) from transactions__r) from customer__c];
Error: DYNAMICAPPROVALCLASS Compile Error: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object. at line 10 column 5

how to write this type of query . 
 
i added command button for every coloum in apex:repeat, if i click on that button then it is invoking wrapper class and displaying the wrapper class rows to all records in apex:repeat ....  i want to only display the wrapper class rows for the specific row only (at which i clicked the button).  please help me. 

The below image is after i cliking on "Add Row" botton on 1st row
User-added image
<apex:page controller="createDynamicTableProcess" >
<apex:form >
<apex:pageblock title="All contacts" >
<apex:repeat value="{!cons}" var="a" >
<table border="1" width="300px;" > <tr> 
<td><apex:outputtext value="{!a.name}" /> <br/></td>
<td><apex:outputtext value="{!a.phone}" /><br/></td>
<td><apex:outputtext value="{!a.account.industry}" /><br/></td>
<td><apex:commandbutton value="Add Row" action="{!createRecordForSubContact}" >
<apex:param name="sending contact id" value="{!a.id}" assignto="{!contactid}" />
</apex:commandbutton>
<br/><br/></td>

</tr> </table> 
  <apex:pageblocktable value="{!scw}" var="a" id="pbt1">
            <apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.name}" onchange="getrec(this.id)" id="v1"/> </apex:column>
            <apex:column ><apex:inputtext value="{!a.country}" onchange="getrec(this.id)" id="v2"/> </apex:column>
   </apex:pageblocktable>

</apex:repeat>
</apex:pageblock>
</apex:form>


</apex:page>
 
public class createDynamicTableProcess {

public list<contact> cons{set;get;}
public string contactid {set;get;}
public list<subcontactwrapper> scw{set;get;}
public createDynamicTableProcess ()
{
    cons=new list<contact>();

    list<string> accids=new list<string>();
        for(account a1:[select id from account])
            {
            accids.add(a1.id);
            }

       cons=[select id,name,phone,account.industry from contact where accountid in:accids limit 10];
} //constructor closed

//method for button click for every contact.
public void createRecordForSubContact()
{
scw=new list<subcontactwrapper>();
subcontactwrapper s1=new subcontactwrapper();
scw.add(s1);


}

public class subcontactwrapper
{
public boolean flag {set;get;}
public string name {set;get;}
public string country {Set;get;}
public date  startdate {Set;get;} 
}
}

 
I created one actionfunction and its name is "callmymethod"   when i click on the button , this method is not calling .   please help. 
<apex:page controller="createDynamicTableProcess" >
<apex:form >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>

function calldata()
{
//alert("this is 2nd alert");
//callmymethod();
//alert("this is 3rd alert");

}
    window.setTimeout(callmymethod,2000);

</script>


<apex:actionfunction name="callmymethod" action="{!insertSubContactRecords}" id="idd1"/>
<apex:pageblock title="All contacts" >
<apex:repeat value="{!cons}" var="a" >
<table border="1" width="300px;" > <tr> 
<td><apex:outputtext value="{!a.name}" /> <br/></td>
<td><apex:outputtext value="{!a.phone}" /><br/></td>
<td><apex:outputtext value="{!a.account.industry}" /><br/></td>
<td><apex:commandbutton value="Add Row"  id="one"  onclick="calldata();">
<!-- <apex:param name="sending contact id" value="{!a.id}" assignto="{!contactid}" /> -->
</apex:commandbutton>
<br/><br/></td>

</tr> </table> 
  <apex:pageblocktable value="{!scw}" var="a" id="pbt1">
            <apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.name}" onchange="getrec(this.id)" id="v1"/> </apex:column>
            <apex:column ><apex:inputtext value="{!a.country}" id="v2"/> </apex:column>
   </apex:pageblocktable>
<center><apex:commandbutton value="Save Checked Records"  ><apex:param value="{!a.id}" assignto="{!SpecificContactRecordId}" />  </apex:commandbutton></center>
</apex:repeat>
</apex:pageblock>
</apex:form>


</apex:page>
 
public class createDynamicTableProcess {

public list<contact> cons{set;get;}
public string contactid {set;get;}
public list<subcontactwrapper> scw{set;get;}
public list<subcontactwrapper> scw2{set;get;}
public string SpecificContactRecordId{set;get;}
public createDynamicTableProcess ()
{
scw=new list<subcontactwrapper>();
scw2=new list<subcontactwrapper>();

    cons=new list<contact>();

    list<string> accids=new list<string>();
        for(account a1:[select id from account])
            {
            accids.add(a1.id);
            }

       cons=[select id,name,phone,account.industry from contact where accountid in:accids limit 1];
} //constructor closed

//method for button click for every contact.
public void createRecordForSubContact()
{
subcontactwrapper s1=new subcontactwrapper();
scw.add(s1);

}

public void insertSubContactRecords()
{
list<subcontact__c> subc=new list<subcontact__c>();
    for(subcontactwrapper s1: scw)
    { 
    
        subcontact__c su=new subcontact__c();
        su.name__c=s1.name;
        su.Country__c= s1.country;
        su.Contact__c=SpecificContactRecordId;
        subc.add(su);
        }
        insert subc;
        
}      
public class subcontactwrapper
{
public boolean flag {set;get;}
public string name{set;get;}
public string country{Set;get;}
}
}


 
i added command button for every coloum in apex:repeat, if i click on that button then it is invoking wrapper class and displaying the wrapper class rows to all columns in apex:repeat ....  i want to only display the wrapper class data for the specific row only.  please help me.

User-added image
Visualforce page:-
<apex:page controller="createDynamicTableProcess" >
<apex:form >
<apex:pageblock title="All contacts" >
<apex:repeat value="{!cons}" var="a" >
<table border="1" width="300px;" > <tr> 
<td><apex:outputtext value="{!a.name}" /> <br/></td>
<td><apex:outputtext value="{!a.phone}" /><br/></td>
<td><apex:outputtext value="{!a.account.industry}" /><br/></td>
<td><apex:commandbutton value="Add Row" action="{!createRecordForSubContact}" >
<apex:param name="sending contact id" value="{!a.id}" assignto="{!contactid}" />
</apex:commandbutton>
<br/><br/></td>

</tr> </table> 
  <apex:pageblocktable value="{!scw}" var="a" id="pbt1">
            <apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.name}" onchange="getrec(this.id)" id="v1"/> </apex:column>
            <apex:column ><apex:inputtext value="{!a.country}" onchange="getrec(this.id)" id="v2"/> </apex:column>
   </apex:pageblocktable>

</apex:repeat>
</apex:pageblock>
</apex:form>


</apex:page>

Apex:controller:-
 
public class createDynamicTableProcess {

public list<contact> cons{set;get;}
public string contactid {set;get;}
public list<subcontactwrapper> scw{set;get;}
public createDynamicTableProcess ()
{
    cons=new list<contact>();

    list<string> accids=new list<string>();
        for(account a1:[select id from account])
            {
            accids.add(a1.id);
            }

       cons=[select id,name,phone,account.industry from contact where accountid in:accids limit 10];
} //constructor closed

//method for button click for every contact.
public void createRecordForSubContact()
{
scw=new list<subcontactwrapper>();
subcontactwrapper s1=new subcontactwrapper();
scw.add(s1);


}

public class subcontactwrapper
{
public boolean flag {set;get;}
public string name {set;get;}
public string country {Set;get;}
public date  startdate {Set;get;} 
}
}

 
i am trying to execute the code in developer console, but i am getting this error. please some one help me. 

Invalid foreign key relationship: Account.contact


 
map<string,list<string>> m2=new map<string,list<string>>();

for(account a1:[select id,name,(select id,lastname,phone from contacts cons) from account])
{
    m2.put(a1.name,a1.contact.phone);
}

 
 
trigger updateacc on contact(after insert,after update)
{
map<id,contact> mymap=new map<id,contact>();

for(contact c:trigger.new)
{
mymap.put(c.id,c);
}

list<account> acc=[select id,name,description from account where id in:mymap.keyset()];

for(account a1:acc)
{
a1.description=mymap.get(a1.id).HomePhone;
update acc;
}
}

 
before this rigger i created an approval process in account object with condition  "annual revenue <10000".     If i am giving amount less than 10000 annual revenue in new account record the trigger is firing and sending auto approval process. but if i enter more than 10000  ... eg:- entering 12000 in annual revenue then clicking on the save button in account object then it is throwing error,   Please help me.

User-added image
 
trigger accountApprovalSubmitAction on Account (after insert) {
for (Account a : trigger.new)
{
Approval.ProcessSubmitRequest appAction = new Approval.ProcessSubmitRequest();
appAction.setObjectId(a.id);
Approval.ProcessResult resultAction = Approval.process(appAction);
}
}

 
i want to run this code only for system admin. But it is firing for all users. 


 
trigger acc_customSetting on Account (before insert) {

    adminonly__c a1=adminonly__c.getInstance(userinfo.getuserid());
    if(a1.valid__c)
    {
    for(account a2:trigger.new)
    {
        a2.description=a2.name+' this is custom setting data';
    }
    }
}

 
here i am confusing how to add text box value at 'where' condition in the ajax query.   This is not working. please help. 

 
<apex:page id="pageId">
<apex:form >
<script src="/soap/ajax/30.0/connection.js" type="text/javascript"></script>
<script>
var text11;
function jaff(myid)
{
var text11=myid.value;
alert(text11);
}
function show() {


<!--   *****************************   Check this below line *******************  -->
var query="Select Name, Industry From Account where industry= "+text11;



     sforce.connection.sessionId = "{!$Api.Session_ID}";              

       var queryResult = sforce.connection.query(query);
        if (queryResult.size > 0) {
                var output = "";
                var records = queryResult.getArray('records');
                var result='';
        for (var i = 0; i <records.length; i++) {
          var account = records[i];
          result += account.Name ;
    }                            
            
                 
        }
    
    document.getElementById('{!$Component.output}').innerHTML=result;
    document.getElementById('{!$Component.output1}').value=result; 
// i u remove the above line then error coming
 
} 

 </script>
 <apex:inputtext id="j1" onchange="jaff(this)" /><br/>
 <apex:commandButton value="click" onclick="show()"  rerender="output" />
    <apex:outputLabel id="output"/>
  
   
</apex:form>  
</apex:page>

 
After filling the rows if i select the specific checkboxes then click on displayvalues button then the data not showing in the 3rd pageblock table. please solve this.   User-added image
 
<apex:page controller="mytextboxwrapper">
    <Apex:form >
    <apex:pageblock >
        <apex:pageblocktable value="{!mt}" var="a" >
                    <apex:column ><apex:inputcheckbox value="{!a.value3}" /> </apex:column>

            <apex:column ><apex:inputtext value="{!a.value1}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.value2}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.value3}" /> </apex:column>
        </apex:pageblocktable>
        <apex:commandButton value="display values"  />
        <apex:commandButton value="display values"  action="{!exactdata}"/>

        

        </apex:pageblock>
        
         <apex:pageblock title="output data" >
        <apex:pageblocktable value="{!mt}" var="a" >
            <apex:column ><apex:outputtext value="{!a.value1}" /></apex:column>
            <apex:column value="{!a.value2}" > </apex:column>
            <apex:column value="{!a.value3}" > </apex:column>
        </apex:pageblocktable>
        </apex:pageblock>
        
          <apex:pageblock title="Selected Data" >
        <apex:pageblocktable value="{!mtt}" var="a" >
            <apex:column ><apex:outputtext value="{!a.value1}" /></apex:column>
            <apex:column value="{!a.value2}" > </apex:column>
            <apex:column value="{!a.value3}" > </apex:column>
        </apex:pageblocktable>
        </apex:pageblock>
                  
    </Apex:form>
</apex:page>















public class mytextboxwrapper {

    public list<mytext> mt{set;get;}
        public list<mytext> mtt{set;get;}

    public mytextboxwrapper()
    {
        mt=new list<mytext>();
        
        for(integer i=0;i<5;i++)
        {
        mytext m1=new mytext();
        mt.add(m1);
        }
      }  
     public void exactdata()
     {
        mtt=new list<mytext>();
        
        for(mytext mtemp:mt)
        {
        if(mtemp.flag==true)
        {
            
             mtt.add(mtemp);
        }
        }
        
     }
    public class mytext {
        
        public string value1{Set;get;}
        public string value2{set;get;}
        public string value3{set;get;}
        public boolean flag{Set;get;}
    }    
}

 
if the new case origin is web then it should add to case team. But i am getting this error. 

  Error: Invalid Data. 
Review all error messages below to correct your data.
The page you submitted was invalid for your session. Please click Save again to confirm your change.

 
trigger casefromweb on Case (after insert) {
CaseTeamTemplate ctt = [Select Id From CaseTeamTemplate where Name = 'second case team' limit 1];
    for(case c1:trigger.new)
    {
       if(c1.Origin=='web')
        {
            CaseTeamTemplateRecord cttr = new CaseTeamTemplateRecord(TeamTemplateId = ctt.Id, ParentId = c1.ParentId);
upsert cttr;
        }
    }
    
}



 
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId] 

Class.eventtestclass.testingeventtrigger: line 17, column 1
 
@istest
public class eventtestclass {

    @istest static void testingeventtrigger()
    {
        opportunity op1=new opportunity();
        op1.name='testingopp1';
        op1.StageName='closed won';
        op1.closedate=date.parse('12/12/2016');
         insert op1;
        
     Event e11 = new Event(whatID = op1.ID, Ownerid = op1.ownerid);
        	e11.ActivityDate=date.today();
        	e11.subject='hello';
	        e11.StartDateTime = Op1.closedate;
	        e11.EndDateTime = Op1.closedate;   
	        insert e11;
        
        opportunity opp=[select id,name,nextstep,description from opportunity limit 1];
        
        string name1=e11.subject + ' ,' + e11.ActivityDate;
        system.assertequals(opp.NextStep,name1);
        
    }
    
}

 
i am getting this error. 
User-added image

 
<apex:page controller="postalcode" readOnly="true">
    <apex:pageblock>
<apex:variable value="{!1}" var="rowNum"/>
        
    <apex:repeat value="{!post}" var="a"  >
       <apex:outputText value="{!FLOOR(rowNum)}"/>...... <apex:outputtext value="{!a.Postal_code__c}" /><br/>
                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
        </apex:repeat>                                      
    
    </apex:pageblock>
    	
</apex:page>











public class postalcode {
    
    public list<Postal_codes__c> post{set;get;}

    public postalcode()
    {
        post=[select id,Postal_code__c from Postal_codes__c limit 2000];
    }
}

 
I have been attempting to write a test class for my search function but its throwing me a little, my first time designing a lightning component so if someone could walk me through it that would I would hugely appreciate it.

ContactList.cmp
<aura:component controller="ContactListController">

    <aura:attribute name="accounts" type="account[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler event="c:SearchKeyChange" action="{!c.searchKeyChange}"/>

    <ul>
        <aura:iteration items="{!v.accounts}" var="account">
            <li>
                <a href="{! '#/sObject/' + account.Id + '/view'}">
                    <p>{!account.Name}</p>
                    <p>{!account.Phone}</p>
                    <p>{!account.BillingStreet}</p>
                </a>
            </li>
        </aura:iteration>
    </ul>
    </aura:component>



ControllerListController.js
({
        doInit : function(component, event) {
            var action = component.get("c.findAll");
            action.setCallback(this, function(a) {
                component.set("v.accounts", a.getReturnValue());
            });
            $A.enqueueAction(action);
        },
    
        
        searchKeyChange: function(component, event) {
        var searchKey = event.getParam("searchKey");
        var action = component.get("c.findByLocation");
        action.setParams({
          "searchKey": searchKey
        });
        action.setCallback(this, function(a) {
            component.set("v.accounts", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
        
    })



ContactListController.apxc
public with sharing class ContactListController {
    
        @AuraEnabled
        public static List<Account> findAll() {
            return [SELECT id, name, BillingStreet, phone FROM Account LIMIT 50];
        }
    
        @AuraEnabled
        public static List<Account> findByLocation(String searchKey) {
            String name = '%' + searchKey + '%';
            return [SELECT id, name, phone, BillingStreet FROM Account WHERE BillingStreet LIKE :name LIMIT 50];
        }
    
        
    
    }



SearchBar.cmp
<aura:component >
        <div>
            <input type="text" class="form-control"
                   placeholder="Search" onkeyup="{!c.searchKeyChange}"/>
        </div>
    </aura:component>



SearchBarController.js

   
({
        searchKeyChange : function(component, event, helper) {
        
        var myEvent = $A.get("e.c:SearchKeyChange");
        myEvent.setParams({"searchKey":event.target.value});
        myEvent.fire();
    
    }
    })

 
hi,  i am getting    "unexpceted token where  error."      please solve this. 

Date dte = Date.today().addDays(-2);
      
         String Name ='dell ';
       String ActName ='Activity ';
       
return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c staus__c !=\''+Name+'\' and type__c=\''+ActName+'\' where actual_End_date__c =: dte '
        return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c  =: Date.today().addDays(-2)');   

i am using this in batch apex start method.  i am getting error at this line at  where condition.     FATAL_ERROR System.QueryException: unexpected token: 'where'  
i added command button for every coloum in apex:repeat, if i click on that button then it is invoking wrapper class and displaying the wrapper class rows to all records in apex:repeat ....  i want to only display the wrapper class rows for the specific row only (at which i clicked the button).  please help me. 

The below image is after i cliking on "Add Row" botton on 1st row
User-added image
<apex:page controller="createDynamicTableProcess" >
<apex:form >
<apex:pageblock title="All contacts" >
<apex:repeat value="{!cons}" var="a" >
<table border="1" width="300px;" > <tr> 
<td><apex:outputtext value="{!a.name}" /> <br/></td>
<td><apex:outputtext value="{!a.phone}" /><br/></td>
<td><apex:outputtext value="{!a.account.industry}" /><br/></td>
<td><apex:commandbutton value="Add Row" action="{!createRecordForSubContact}" >
<apex:param name="sending contact id" value="{!a.id}" assignto="{!contactid}" />
</apex:commandbutton>
<br/><br/></td>

</tr> </table> 
  <apex:pageblocktable value="{!scw}" var="a" id="pbt1">
            <apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.name}" onchange="getrec(this.id)" id="v1"/> </apex:column>
            <apex:column ><apex:inputtext value="{!a.country}" onchange="getrec(this.id)" id="v2"/> </apex:column>
   </apex:pageblocktable>

</apex:repeat>
</apex:pageblock>
</apex:form>


</apex:page>
 
public class createDynamicTableProcess {

public list<contact> cons{set;get;}
public string contactid {set;get;}
public list<subcontactwrapper> scw{set;get;}
public createDynamicTableProcess ()
{
    cons=new list<contact>();

    list<string> accids=new list<string>();
        for(account a1:[select id from account])
            {
            accids.add(a1.id);
            }

       cons=[select id,name,phone,account.industry from contact where accountid in:accids limit 10];
} //constructor closed

//method for button click for every contact.
public void createRecordForSubContact()
{
scw=new list<subcontactwrapper>();
subcontactwrapper s1=new subcontactwrapper();
scw.add(s1);


}

public class subcontactwrapper
{
public boolean flag {set;get;}
public string name {set;get;}
public string country {Set;get;}
public date  startdate {Set;get;} 
}
}

 
Hi guys,

I have custom opportunity field named Total_Amount__c.
I need to get Top 5 accounts with opportunities based on Total Amount.
Need to code above(not in reports)

Note: Consider if an account have 5 opps, then the sum of 5 opp fields need to be taken into consideration.


Thanks in advance,
 
User-added image
<apex:page controller="StandardAccount" >
    <apex:form >
    	<apex:pageBlock >
            <apex:pageBlockSection >
            	<apex:inputText label="AccountName" value="{!name}"/>
                <apex:commandButton value="Search" action="{!search}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockTable value="{!accs}" var="a">
    <apex:column >
            <apex:inputCheckbox/>{!a.name} <br/><br/>
            <apex:inputCheckbox/>{!a.phone}<br/><br/>
            <apex:inputCheckbox/>{!a.industry}<br/><br/>
    </apex:column>
</apex:pageBlockTable>
</apex:pageBlock> </apex:form>
</apex:page>

apex program:

public class StandardAccount {
    public List<Account> accs{set;get;}
    public string Name {set;get;}
    public StandardAccount(){
        accs=new List<Account>();
    }
    public void search(){
        accs=[select id,name,phone,industry from Account where name=:name];
    }
    public class StandardAccountwrapper {
    public List<Account> acc{set;get;}
    public StandardAccountwrapper(){
        acc=new List<Account>();
    }
}
}

I am wondering if I have to query other stages with prospecting so how I wrote below soql query:1
String query = 'Select Id, Name, Stage_change_reminder_count__c,StageName From Opportunity WHERE StageName = \'Prospecting\', \'Value Proposition\', \'Process Review\',\’ Validation\' and Open_Tasks__c=0 and Last_Activity_Age__c >=12 ';
But it’s not working why? cann any one help me please.
 
here i am confusing how to add text box value at 'where' condition in the ajax query.   This is not working. please help. 

 
<apex:page id="pageId">
<apex:form >
<script src="/soap/ajax/30.0/connection.js" type="text/javascript"></script>
<script>
var text11;
function jaff(myid)
{
var text11=myid.value;
alert(text11);
}
function show() {


<!--   *****************************   Check this below line *******************  -->
var query="Select Name, Industry From Account where industry= "+text11;



     sforce.connection.sessionId = "{!$Api.Session_ID}";              

       var queryResult = sforce.connection.query(query);
        if (queryResult.size > 0) {
                var output = "";
                var records = queryResult.getArray('records');
                var result='';
        for (var i = 0; i <records.length; i++) {
          var account = records[i];
          result += account.Name ;
    }                            
            
                 
        }
    
    document.getElementById('{!$Component.output}').innerHTML=result;
    document.getElementById('{!$Component.output1}').value=result; 
// i u remove the above line then error coming
 
} 

 </script>
 <apex:inputtext id="j1" onchange="jaff(this)" /><br/>
 <apex:commandButton value="click" onclick="show()"  rerender="output" />
    <apex:outputLabel id="output"/>
  
   
</apex:form>  
</apex:page>

 
After filling the rows if i select the specific checkboxes then click on displayvalues button then the data not showing in the 3rd pageblock table. please solve this.   User-added image
 
<apex:page controller="mytextboxwrapper">
    <Apex:form >
    <apex:pageblock >
        <apex:pageblocktable value="{!mt}" var="a" >
                    <apex:column ><apex:inputcheckbox value="{!a.value3}" /> </apex:column>

            <apex:column ><apex:inputtext value="{!a.value1}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.value2}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.value3}" /> </apex:column>
        </apex:pageblocktable>
        <apex:commandButton value="display values"  />
        <apex:commandButton value="display values"  action="{!exactdata}"/>

        

        </apex:pageblock>
        
         <apex:pageblock title="output data" >
        <apex:pageblocktable value="{!mt}" var="a" >
            <apex:column ><apex:outputtext value="{!a.value1}" /></apex:column>
            <apex:column value="{!a.value2}" > </apex:column>
            <apex:column value="{!a.value3}" > </apex:column>
        </apex:pageblocktable>
        </apex:pageblock>
        
          <apex:pageblock title="Selected Data" >
        <apex:pageblocktable value="{!mtt}" var="a" >
            <apex:column ><apex:outputtext value="{!a.value1}" /></apex:column>
            <apex:column value="{!a.value2}" > </apex:column>
            <apex:column value="{!a.value3}" > </apex:column>
        </apex:pageblocktable>
        </apex:pageblock>
                  
    </Apex:form>
</apex:page>















public class mytextboxwrapper {

    public list<mytext> mt{set;get;}
        public list<mytext> mtt{set;get;}

    public mytextboxwrapper()
    {
        mt=new list<mytext>();
        
        for(integer i=0;i<5;i++)
        {
        mytext m1=new mytext();
        mt.add(m1);
        }
      }  
     public void exactdata()
     {
        mtt=new list<mytext>();
        
        for(mytext mtemp:mt)
        {
        if(mtemp.flag==true)
        {
            
             mtt.add(mtemp);
        }
        }
        
     }
    public class mytext {
        
        public string value1{Set;get;}
        public string value2{set;get;}
        public string value3{set;get;}
        public boolean flag{Set;get;}
    }    
}

 
if the new case origin is web then it should add to case team. But i am getting this error. 

  Error: Invalid Data. 
Review all error messages below to correct your data.
The page you submitted was invalid for your session. Please click Save again to confirm your change.

 
trigger casefromweb on Case (after insert) {
CaseTeamTemplate ctt = [Select Id From CaseTeamTemplate where Name = 'second case team' limit 1];
    for(case c1:trigger.new)
    {
       if(c1.Origin=='web')
        {
            CaseTeamTemplateRecord cttr = new CaseTeamTemplateRecord(TeamTemplateId = ctt.Id, ParentId = c1.ParentId);
upsert cttr;
        }
    }
    
}



 
senario is that, if we create a new event on a account object then it should update the description field of account.  But it is not wokring. 
 
trigger event on Event (after insert) {
set<id> ids=trigger.newmap.keyset();

map<id,event> newevents =new map<id,event>();

 for(event e1:trigger.new)
 {
 if(((String)e1.whatid).startsWith('001')) {
 newevents.put(e1.id,e1);
  }
 }
// account acc=[select id,name,description from account where id in:newevents.keyset()];
 
 for(account a1:[select id,name,description from account where id in:newevents.keyset()])
 {

a1.description=newevents.get(a1.id).location;
update a1;
 
}
}

 
i want to auto populate the picklist after selecting a lookup field.  please help me.


User-added image
 
<apex:page Controller="OppContactRoleController" id="p1">
<script>
var ContactValue='';
function changeValue(input) {

 asChangePrimary(input.value);

}  

function ValidateRoles(input,objSelection,Object) {

 if(input.value!='--None--'){
 if(ContactValue!=''){
 alert('Please select '+Object);
 }
}
}
function setContact(convalue){

ContactValue=convalue;

} 
    
    function getvalue(myinput)
    {
        //  var x=document.getElementById('p1:fm:pb2:pbt:c1:opp:contactid').value;
        //alert(x);
        // alert(myinput.value);
        var y=myinput.value;
        document.getElementById('p1:fm:iph').value=y;
            }
            
</script>
           <apex:form id="fm" >
                 <apex:actionfunction name="getvalue" action="{!getcontactrole}" />

				<!-- do not remove this -->
               <apex:inputtext value="{!mylookupvalue}" id="iph" >
               <!--    <apex:actionsupport event="on" action="{!getcontactrole}" /> -->
               </apex:inputtext>
                 <!-- *********************** -->
           <apex:pageMessages id="pgmsg" />
            <apex:actionFunction action="{!setPrimary}" name="asChangePrimary" rerender="hdn">
             <apex:param name="PrimaryContact" assignTo="{!PrimaryContact}" value="" />
           </apex:actionFunction>
           <apex:actionFunction action="{!SaveAll}" name="RemoveExcessOncomplete"  rerender="pb2">
           
           </apex:actionFunction>
           
            <apex:pageBlock id="pb1" title="Contact Role and Partner Merge" rendered="{!!ShowView}">
            <apex:pageBlockButtons location="top">      
            
             <a class="btn" style="text-decoration: none;" href="{!$Page.OppcontactRolePage}?Id={!strId}&IsInline=1&IsNew=1" target="_top">New Project Firm</a>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!lstMainConAccRoleWrap}" var="l">
              <apex:column headerValue="Action">
              <apex:outputPanel >
               <apex:outputLink style="color:#015ba7" value="{!$Page.OppcontactRolePage}?Id={!strId}&IsInline=1" target="_top">Edit</apex:outputLink>
                 
                 <span style="color:#015ba7">|</span> </apex:outputPanel>
                  <apex:commandlink style="color:#015ba7" value="Del" onclick="return confirm('Are you sure?');" target="_top" action="{!DelOCR}" >
                   <apex:param value="{!l.iIndex}" name="RowIndex" assignTo="{!RowIndex}"/>
                  <apex:param value="{!l.RecordId}" name="delRecordId" assignTo="{!delRecordId}"/>
                 </apex:commandlink>
                 </apex:column>
                <apex:column headerValue="Project Firm" value="{!l.objAcc.Name}"/>
  
                <apex:column headerValue="Company City" value="{!l.objAcc.BillingCity}"/>
                <apex:column headerValue="Company State" value="{!l.objAcc.BillingState}"/>
                <apex:column headerValue="Firm Role">
                <apex:outputPanel > {!l.objOPR.Role}  </apex:outputPanel>
                </apex:column>
                 <apex:column headerValue="Contact Role">
                <apex:outputPanel > {!l.objOCR.Role}  </apex:outputPanel>
                </apex:column>
                <apex:column HeaderValue="Contact" value="{!l.objOCR.ContactId}"/>
              
                <apex:column HeaderValue="Primary">
                <apex:outputPanel rendered="{!!l.objOCR.IsPrimary}"><img src="/img/checkbox_unchecked.gif" alt="Not Checked" width="21" height="16" class="checkImg" title="Not Checked"/></apex:outputPanel>
                <apex:outputPanel rendered="{!l.objOCR.IsPrimary}"><img src="/img/checkbox_checked.gif" alt="Checked" width="21" height="16" class="checkImg" title="Checked"/> </apex:outputPanel>
                </apex:column>                
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageblock id="pb2" rendered="{!ShowView}">
      
            <apex:pageBlockTable value="{!lstMainConAccRoleWrap}" var="l" id="pbt">
          <apex:column headervalue="Action">
        
            <apex:commandLink rendered="{!if(l.RecordId!='',true,false)}" value="Delete" onclick="return confirm('Are you sure ?');" action="{!DelOCR}" 
            style="color:#015ba7;">
            <apex:param value="{!l.iIndex}" name="RowIndex" assignTo="{!RowIndex}"/>
            <apex:param value="{!l.RecordId}" name="delRecordId" assignTo="{!delRecordId}"/>
            </apex:commandLink>
            <apex:outputLink rendered="{!if(l.RecordId=='',true,false)}" onclick="return confirm('Are you sure ?');" style="color:#015ba7" value="{!$Page.OppcontactRolePage}?Id={!strId}&IsInline=1" target="_top">Delete</apex:outputLink>
            </apex:column>
            
            <apex:column headervalue="Primary">
            <apex:outputPanel >
            <apex:outputPanel rendered="{!If(l.IsPrimary,true,false)}">
            <input type="radio" checked="true" name="chosen" id="{!l.RecordId}" VALUE="{!l.RecordId}" onclick="changeValue(this);" />
            </apex:outputPanel>
             <apex:outputPanel rendered="{!If(l.IsPrimary,false,true)}">
             <input type="radio"  name="chosen" id="{!l.RecordId}" VALUE="{!l.RecordId}" onclick="changeValue(this);" />
            </apex:outputPanel>
            </apex:outputPanel>

            </apex:column> 
            
            <apex:column headerValue="Contact" id="c1">
            <apex:outputPanel id="opp">
             <apex:inputField required="false"  value="{!l.objOCR.ContactId}" id='contactid'  >
               <apex:actionsupport event="onchange" action="{!getcontactrole}" />
                 <!-- action support added for sending value to apex class.-->
              <!--  <apex:actionsupport event="onchage" action="{!getcontactrole}" />  -->
                </apex:inputField>
             </apex:outputPanel>
             </apex:column> 
             
            <apex:column headerValue="Contact Role">
                    <apex:inputField value="{!l.objOCR.Role}" >
                   
                    </apex:inputField>
              </apex:column> 
             <apex:column headerValue="Account">
               <apex:outputPanel > 
              <apex:inputField value="{!l.objCon.AccountId}"/>
             </apex:outputPanel>
             </apex:column> 
             <apex:column headerValue="Partner Role">
               <apex:outputPanel > 
                  <apex:selectList value="{!l.objOPR.Role}" size="1" multiselect="false">
                    <apex:selectOptions value="{!OPRRoleOptions}"></apex:selectOptions>
                  </apex:selectList>
                 </apex:outputPanel> 
                  <!--   <apex:inputField rendered="{!if(l.objOCR==null,false,true)}" value="{!l.objOCR.Role}" />
                  <apex:inputField rendered="{!if(l.objOCR==null,true,false)}" value="{!l.objOPR.Role}" />  -->
             </apex:column> 
  
                 
            </apex:pageBlockTable>

         <apex:pageBlockButtons location="bottom">  
         <apex:commandButton value="Save" action="{!SaveAll}"     />

          <apex:commandButton value="New" onclick="SavePage();" rerender="pb2,pgmsg"   />
          <apex:commandButton value="Back" action="{!Back}"    />
         </apex:pageBlockButtons>
        </apex:pageblock>
        <apex:actionFunction action="{!QuickSave}" oncomplete="AddNew();" name="SavePage" rerender="pb2,pgmsg"  />
        <apex:actionFunction action="{!AddNew}" rerender="pb2,pgmsg" name="AddNew"/>
      ...........{!cons.role__c}
    </apex:form>
</apex:page>
 
public with sharing class OppContactRoleController {

   Public List<Contact> contactList {get;set;}
    
    public boolean ShowView{get;set;}
    public String strId{get;set;}
    public string PrimaryContact{get;set;}   
    Id OCRId;  
    public string delRecordId{get;set;}   
    Map<string,string> mapOCR=new Map<string,string>();
    string FirstPrimaryContact;
    public integer RowIndex{get;set;}
    set<Id> conIds = new Set<Id>();
    
    public string PrimaryAccount{get;set;} 
    public string delOPRId{get;set;}   
    Map<string,string> mapOPR=new Map<string,string>();
    string FirstPrimaryAccount; 
    set<Id> AccIds = new Set<Id>();
   
    /*  New Approach */
    List<Account> lstAcc=new List<Account>();
    public list<MainConAccRoleWrap> lstMainConAccRoleWrap{get;set;}
    List<OpportunityContactRole> lstOCR=new List<OpportunityContactRole>();
    List<Partner> lstOPR=new List<Partner>();
    Map<Id,Account> mapIDAcc=new Map<Id,Account>();
    Map<Id,Contact> mapIDCon=new Map<Id,Contact>();
    public List<SelectOption> OPRRoleOptions{get;set;} 
    set<string> setOPRRole=new set<string>();
    Map<string,integer> MapMerge=new Map<string,integer>(); // Account,Role
    set<integer> MergeIndex=new set<integer>();
    Map<string,integer> MapParterAccId=new Map<string,integer>();
    
    // modification code for contact role auto populate.
    public string mylookupvalue{get;set;}
    public contact cons{get;set;}
    public void getcontactrole()
    {
      cons=[select id,name,role__c from contact where name=:mylookupvalue limit 1];
    }
    
    Public OppContactRoleController (){//ApexPages.StandardController cntrl
    try{
     
    }catch(exception ex){
        
        system.debug('------Error------'+ex.getMessage()+'-----ar Line #----------'+ex.getLineNumber());
    }   
    OPRRoleOptions= new List<SelectOption>();
    lstMainConAccRoleWrap=new list<MainConAccRoleWrap>();
    
    
    RowIndex=-1;
    try{
    strId=ApexPages.currentPage().getParameters().get('Id');
    ShowView=false;
    string IsNew=ApexPages.currentPage().getParameters().get('IsNew');
    string IsInline=ApexPages.currentPage().getParameters().get('IsInline');
 
    if(IsInline=='1'){
    ShowView=true;
    
    }
    OPRRoleOptions();
    
    contactList = new List<Contact>();
    
    for(OpportunityContactRole cRole :[Select Id,ContactId,IsPrimary,Role from OpportunityContactRole where Role!=null and OpportunityId =: strId]){
      
     if(cRole.IsPrimary){
           PrimaryContact=cRole.Id;
           FirstPrimaryContact=cRole.Id;
        } 
        lstOCR.add(cRole);
        conIds.add(cRole.ContactId);
    }
    
    for(Partner oRole :[Select Id,AccountToId,IsPrimary,Role from Partner where  Role!=null and AccountToId!=null and AccountFromId=null and OpportunityId =: strId]){

        lstOPR.add(oRole);
        AccIds.add(oRole.AccountToId);
        integer PartnerOccurCount=MapParterAccId.get(oRole.AccountToId)==null?0:MapParterAccId.get(oRole.AccountToId);
       // MapParterAccId.put(oRole.AccountToId,PartnerOccurCount++);
    }
    
 
    contactList = [Select Id, Name, AccountId from Contact where Id in: conIds];

    for(Contact ObjCon:contactList){

     mapIDCon.put(ObjCon.Id,ObjCon);
     AccIds.add(ObjCon.AccountId);
    }
    
    lstAcc=[Select Id, Name,BillingStreet,BillingCity, BillingState, BillingCountry  from Account where Id in: AccIds];
    for(Account ObjAcc:lstAcc){
     mapIDAcc.put(ObjAcc.Id,ObjAcc);
    }
    integer i=0;
    for(OpportunityContactRole objOCR:lstOCR){
       
    lstMainConAccRoleWrap.add(new MainConAccRoleWrap(objOCR.Id,objOCR,new Partner(),mapIDAcc.get(mapIDCon.get(objOCR.ContactId).AccountId),objOCR.IsPrimary,lstMainConAccRoleWrap.size(),new Contact(AccountId=mapIDCon.get(objOCR.ContactId).AccountId)));
    MapMerge.put(String.ValueOf(mapIDCon.get(objOCR.ContactId).AccountId),i); 
    i++;    
    }
    
    for(Partner objOPR:lstOPR){
 
    If(!MapMerge.Keyset().Contains(String.ValueOf(objOPR.AccountToId))){
     lstMainConAccRoleWrap.add(new MainConAccRoleWrap(objOPR.Id,new OpportunityContactRole(OpportunityId=strId),objOPR,mapIDAcc.get(objOPR.AccountToId),objOPR.IsPrimary,lstMainConAccRoleWrap.size(),new Contact(AccountId=objOPR.AccountToId)));
    }
    else{
        
    integer IndexUpd=MapMerge.get(String.ValueOf(objOPR.AccountToId));
    if(!MergeIndex.Contains(IndexUpd)){
    MainConAccRoleWrap objUpd=lstMainConAccRoleWrap[IndexUpd];
    string RecordId=objUpd.RecordId+','+objOPR.Id;
    objUpd.RecordId=RecordId;
    objUpd.objOPR=objOPR;
    objUpd.IsPrimary=objOPR.IsPrimary;
    objUpd.objAcc=mapIDAcc.get(objOPR.AccountToId);
    objUpd.objCon=new Contact(AccountId=objOPR.AccountToId);
    lstMainConAccRoleWrap[IndexUpd]=objUpd;
    MergeIndex.add(IndexUpd);
    }
    }   
    }
    
    
    
    
    
    
    if(IsNew=='1'){
        ShowView=true;
        lstMainConAccRoleWrap.add(new MainConAccRoleWrap(null,new OpportunityContactRole(OpportunityId=strId),new Partner(),new Account(),false,lstMainConAccRoleWrap.size(),new Contact()));
    
    }
    }
    catch(Exception Ex){
     system.debug('-------Exception-------'+ex.getMessage()+'------at Line #-----'+ex.getLineNumber());
    }
    delRecordId=null;
      system.debug('---lstMainConAccRoleWrap--Load-'+lstMainConAccRoleWrap);  
    }

    
    Public class MainConAccRoleWrap{


        public OpportunityContactRole objOCR{get;set;}
        public Partner objOPR{get;set;}
        public boolean IsPrimary{get;set;}
        public integer iIndex{get;set;}
        //public Contact objCon{get;set;} Contact objCon1,
        public Account objAcc{get;set;}
        public string RecordId{get;set;}
        //public List<SelectOption> ObjOPRole{get;set;}
        public Contact objCon{get;set;}
        // string RecordId,OpportunityContactRole objOCR,Partner objOPR,Account objAcc,boolean IsPrimary,integer iIndex,Contact objCon
        public MainConAccRoleWrap(string RecordId1,OpportunityContactRole objOCR1,Partner objOPR1,Account objAcc1,boolean IsPrimary1,integer iIndex1,Contact objCon1){
        
        this.RecordId=RecordId1;
        this.objOCR=objOCR1;
        this.objOPR=objOPR1;
        this.IsPrimary=IsPrimary1;  
        this.iIndex=iIndex1;
        //this.objCon=objCon1;
        this.objAcc=objAcc1;
        this.objCon=objCon1;
        }
        
    }
    

    
    
    
    public void AddNew(){
    ShowView=true;
    lstMainConAccRoleWrap.add(new MainConAccRoleWrap(null,new OpportunityContactRole(OpportunityId=strId),new Partner(),new Account(),false,lstMainConAccRoleWrap.size(),new Contact()));
    }
    
    public void RemoveExcess(){
    ShowView=true;
    System.debug('----------contactList----------'+contactList);
    }
    
    public void setPrimary(){
    system.debug('---PrimaryContact ---'+PrimaryContact );
    
    }
    
    public pageReference DelOCR(){
    
     if(!string.IsEmpty(delRecordId)){
      delRecordId= lstMainConAccRoleWrap[RowIndex].RecordId;
	   if(delRecordId.contains(',')){
	     string[] delArr=delRecordId.split(',');
	     Database.delete(delArr[0]); 
	     Database.delete(delArr[1]); 
	   }
	   else{
	   	 Database.delete(delRecordId);
	   }
   
    }
    ShowView=false;
    pageReference pg=new PageReference('/'+strId);
    pg.setredirect(true);
    return pg;
    }
    
    public pageReference Back(){
    
    pageReference pg=new PageReference('/'+strId);
    //pageReference pg=new PageReference('/apex/OppcontactRolePage?Id=00617000005UyFO&IsInline=1');
    pg.setredirect(true);
    return pg;
    
    }
    
    
    public void PrepareView(){
        
          try{      
        system.debug('---lstMainConAccRoleWrap---Save--'+lstMainConAccRoleWrap);  
        
        
    List<OpportunityContactRole> lstOCRDML=new List<OpportunityContactRole>();
    List<Partner> lstOPRDML=new List<Partner>();
    // string RecordId,OpportunityContactRole objOCR,Partner objOPR,Account objAcc,boolean IsPrimary,integer iIndex,Contact objCon
    set<string> setPartnerAcc=new set<string>();
    for(MainConAccRoleWrap objMCA:lstMainConAccRoleWrap){ 
        
    if(objMCA.objOCR.ContactId!=null && objMCA.objOCR.Role!=null && objMCA.objOCR.Role!='--None--'){
        
        if(PrimaryContact==objMCA.RecordId){
        objMCA.objOCR.IsPrimary=true;
        }

        lstOCRDML.add(objMCA.objOCR);
       
        
    }
    
    
   // if(objMCA.objOPR.Role!=null && objMCA.objOPR.Role!='--None--'){ //objMCA.objCon.AccountId!=null && 
       String PartnerAccId='';
       if(objMCA.objCon!=null && objMCA.objCon.AccountId!=null){
       	PartnerAccId=objMCA.objCon.AccountId;
       }
       else{
	       if(!string.IsEmpty(objMCA.objOCR.ContactId)){
		       if(mapIDCon.get(objMCA.objOCR.ContactId)!=null){
		        PartnerAccId=mapIDCon.get(objMCA.objOCR.ContactId).AccountId;	
		       }
		       else{
		       	PartnerAccId=[select AccountId from Contact where Id=:objMCA.objOCR.ContactId].AccountId;
		       }
	       }
       }
       //integer PartnerOccurCount=MapParterAccId.get(PartnerAccId)==null?0:MapParterAccId.get(PartnerAccId);
      // PartnerOccurCount<=1 &&
       if(!string.IsEmpty(PartnerAccId) &&  !setPartnerAcc.contains(PartnerAccId)){ 
	       Partner objPartNew=new Partner(); 
	       objPartNew.Role=objMCA.objOPR.Role;
	       objPartNew.AccountToId=PartnerAccId;
	       if(PrimaryContact==objMCA.RecordId){
	       		objPartNew.IsPrimary=objMCA.IsPrimary;
	       }
	       objPartNew.OpportunityId=strId;
	       lstOPRDML.add(objPartNew); 
	       //if(PartnerOccurCount==0){
	      //   MapParterAccId.put(PartnerAccId,PartnerOccurCount++);
	       //}
	       setPartnerAcc.add(PartnerAccId);
       }
    //  }
  
  
    }
    
    if(!lstOCRDML.IsEmpty()){

    Upsert lstOCRDML;
    }
    
    Delete[select Id from Partner where OpportunityId=:strId]; 
    if(!lstOPRDML.IsEmpty()){
       Upsert lstOPRDML;
    }   
    

    ShowView=false;
   
    
    }catch(exception ex){
        
        system.debug('------Error------'+ex.getMessage()+'-----ar Line #----------'+ex.getLineNumber());
             ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'------Error------'+ex.getMessage()+'-----ar Line #----------'+ex.getLineNumber());
            ApexPages.addMessage(myMsg);
       
    }
    } 
    
    
    
    public pageReference SaveAll(){
     PrepareView();
     pageReference pg=new PageReference('/'+strId);
     pg.setredirect(true);
     return pg;
    }
    
    
    public void QuickSave(){
   
    PrepareView();

    }
    

   public void OPRRoleOptions()
   {
       Schema.DescribeFieldResult fieldResult = Partner.Role.getDescribe();
       List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        OPRRoleOptions.add(new SelectOption('--None--', '--None--'));    
       for( Schema.PicklistEntry f : ple)
       {
          OPRRoleOptions.add(new SelectOption(f.getLabel(), f.getValue()));
          setOPRRole.add(f.getLabel());
       }       
      
   }
    
    
}


 
Hi dides, i wrote a test class for my trigger.    After inserting record in a custom object my trigger will create a salesforce user. Trigger is working well, and test code is also success, But code coverage is not coming. Please help me.
 
trigger copytouserobject on newchatter__c (before insert) {
    list<user> allusers=new list<user>();
 //   list<profile> p1=[ select id from profile where id = '00e28000000oU4t' limit 1];
    Profile p = [SELECT Id FROM Profile WHERE Name='Chatter Free User'];



    for(newchatter__c n1:trigger.new)
    {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = true;       
dmo.EmailHeader.triggerOtherEmail = true;
dmo.EmailHeader.triggerAutoResponseEmail = true;       
dmo.optAllOrNone = true;
//above anuradha code

        //n1.first_name__c='hello';
        user u1=new user();
        u1.FirstName=n1.First_Name__c;
        u1.LastName=n1.Last_Name__c;
        u1.Alias=n1.Alias__c; 
        u1.Email=n1.Email__c;
        u1.CommunityNickname=n1.Nickname__c;
        u1.username=n1.Username__c;
     //   u1.Profileid ='00e28000000oU4t';
     u1.Profileid=p.id;
     //   u1.CurrencyIsoCode = 'USD';
u1.localesidkey='en_US';
u1.timezonesidkey='America/Los_Angeles';
u1.EmailEncodingKey = 'ISO-8859-1';
u1.LanguageLocaleKey = 'en_US';
//u1.UserPermissionsMobileUser = false;
u1.RECEIVESINFOEMAILS=true;
u1.RECEIVESADMININFOEMAILS=true;
//u1.resetpassword=true;
        allusers.add(u1);


u1.setOptions(dmo);
    }
    insert allusers;

}

 Test class code.
 
@istest
public class newchattertest {

    @istest static void mytest()
    {
newchatter__c n1=new newchatter__c();
n1.Alias__c ='mydog';
n1.Email__c='prasanth523001@gmail.com';
n1.First_Name__c='somex';
n1.Last_Name__c='somey';
n1.Nickname__c='nothing';
n1.Username__c='testing6789rtr@gmail.com';
	  
        insert n1;
        
        user u=[select id,firstname,lastname,alias,email,CommunityNickname,username,Profileid,localesidkey,timezonesidkey,EmailEncodingKey,LanguageLocaleKey,RECEIVESINFOEMAILS, RECEIVESADMININFOEMAILS from user where Alias ='mydog' limit 1];
    
        system.assertEquals('somex',u.firstname );
system.assertEquals('somey',u.lastname );
system.assertEquals('mydog',u.alias );
system.assertEquals('prasanth523001@gmail.com',u.email );
system.assertEquals('nothing',u.CommunityNickname );
system.assertEquals('00e28000000oU4t',u.Profileid );
system.assertEquals('testing6789rtr@gmail.com',u.username );
system.assertEquals('en_US',u.localesidkey );
system.assertEquals('America/Los_Angeles',u.timezonesidkey );
system.assertEquals('ISO-8859-1',u.EmailEncodingKey );
system.assertEquals('en_US',u.LanguageLocaleKey );
system.assertEquals(true,u.RECEIVESINFOEMAILS );
system.assertEquals(true,u.RECEIVESADMININFOEMAILS );
        
    }   
}

 
hi dudes,  If i enter a record in  newchatter__c object then a new user record should be created in user object. Upto here working, after trigger inserting the data to user object the new user record is creating but confirmation email not sending to him,   Please help.......   
 
trigger copytouserobject on newchatter__c (after insert) {
    list<user> allusers=new list<user>();
 //   list<profile> p1=[ select id from profile where id = '00e28000000oU4t' limit 1];
    for(newchatter__c n1:trigger.new)
    {
        user u1=new user();
        u1.FirstName=n1.First_Name__c;
        u1.LastName=n1.Last_Name__c;
        u1.Alias=n1.Alias__c; 
        u1.Email=n1.Email__c;
        u1.CommunityNickname=n1.Nickname__c;
        u1.username=n1.Username__c;
        u1.Profileid ='00e28000000oU4t';
     //   u1.CurrencyIsoCode = 'USD';
u1.localesidkey='en_US';
u1.timezonesidkey='America/Los_Angeles';
u1.EmailEncodingKey = 'ISO-8859-1';
u1.LanguageLocaleKey = 'en_US';
u1.UserPermissionsMobileUser = false;
        allusers.add(u1);
    }
    insert allusers;

}


below are created users but, verificaion email not sent to them. 
User-added image

Here is a reduced snippet of what I have so far:

 

<apex:page standardController="Case" extensions="NrtListController">
	<apex:param name="caseID" value="{!Case.id}"/>
	Standard CaseID: {!Case.id}
	Extension CaseID: {!CaseNrt}
</apex:page>

public class NrtListController {
	public NrtListController(ApexPages.StandardController controller) {}
	public String getCaseNrt(){
        	return System.currentPagereference().getParameters().get('caseID');
	}
}

 

 

This page returns

Standard CaseID: 500T0000002mTLlIAM

Extension CaseID:

 

How can I get the current objects ID to the extension controller (The extension CaseID should be the same as the Standard CaseID)?

 

Thanks,

Matt

 

  • April 16, 2011
  • Like
  • 0
Hi,  i am trying to display wrapper class data in lighning page. But noting is coming. But in cosole.log data is coming. Please help me to findout this thing.   

 
public class accwrapperclass {

    public class accwrapper
    {
      @AuraEnabled  public account acc{set;get;}
      @AuraEnabled  public boolean check{set;get;}
    }
}



public class selectedaccountslight {
 
    
    @auraEnabled
    public static list<accwrapperclass.accwrapper> getalldatas()
    {
        list<accwrapperclass.accwrapper> accWrapperList = new list<accwrapperclass.accwrapper>();
        
        for(account a1:[select id,name,phone,industry from account ])
        {
            accwrapperclass.accwrapper aw1 = new accwrapperclass.accwrapper();
            aw1.check= false;
            aw1.acc = a1;
            accWrapperList.add(aw1);
            
        }
        return accWrapperList;
    }

}








<aura:component controller="selectedaccountslight">
           <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
   <aura:attribute name="accwrappervalues" type="accwrapperclass.accwrapper[]" /> 

    <aura:iteration items="{!v.accwrappervalues}" var="data">
    {!data.check}....  
    
    
    </aura:iteration>
	
</aura:component>











({
	myAction : function(component, event, helper) {
        
        var action = component.get("c.getalldatas");
 console.log("hello raja");
        
        //Setting the Callback
            action.setCallback(this,function(a){
                //get the response state
                var state = a.getState();
                		  console.log("hello raja2");

                //check if result is successfull
                if(state == "SUCCESS"){
                    
                    var wrapdata = a.getReturnValue();
                    console.log("The wrapdata is: " ,wrapdata);
                  component.get("v.accwrappervalues",wrapdata);
                    
                } 
            });
            
            //adds the server-side action to the queue        
            $A.enqueueAction(action);
		  console.log("hello raja3");
	}
})