• nitin sharma
  • NEWBIE
  • 105 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 32
    Replies
trigger realtime1 on Contact (after insert)
{
set<id> set1=new set<id>();
list<account> aclist=new list<account>();
list<account> acnewlist=new list<account>();
list<Account> listac=new list<account>();
for(contact con:trigger.new)
   {
    set1.add(con.accountid);
   }
  acnewlist=[select id,name,billingaddress
                from account where id in:set1];
  for(contact con:trigger.new)
  {
    for(integer i=0;i<acnewlist.size();i++)
    {
     if(con.accountid==acnewlist[i].id)
     {
      con.account.sales_rep__c=con.department;
      aclist.add(con.account);
     }
   }
  }
update aclist;
}
I'm getting the following error in a knowledge article controller that i'm working on:
Article__kav article1 = new Article__kav();
article1 = [select  URLName, id, Title,Partners__c,Cisco_Account__c, Article_Text__c,(select DataCategoryGroupName, DataCategoryName From DataCategorySelections) from Article__kav where publishstatus='Online' and Language = 'en_US' limit 1];
 system.debug(article1+'aaaaa+');
Any ideas on how I could edit this?
Hi,

I created a custom object called "Account status". I also created a custom field on the account that will store the "Status" value of the account status when it is created and edited. This is working fine. I then created a "Previous Status" field on the account. I created a workflow rule and field update with the formula "TEXT(PRIORVALUE( Rating__c ))". This is working on the edit  properly. However, on the creation of a new "Account Status" object, the priorvalue funtion is returning the "Status" value of the new object. Is there a way to get the previous value on new object creation?
Hi , I have gone through the apex guide .However,I still have one doubt ,I hope to get some answer here.

What is the difference between reading and writing using XMLReader class and Reading and Writing XML Using the DOM.

I feel that I can use any of the methods to accomplish my task of parsing the XML response.Is that correct?I am wrong please guide me with the proper explanation.

HI All,

Whenever I write code for creating visual force pages .I have noticed lines get blurry and it is really tough to write code.I am not sure if others are having this problem or not.Anyonw with the same problem.I have tried writing code by enablling the developmet mode and also setup-----develop-----pages.
I have same problem .Is there anytihng that can be done.Please advice.

This is my personal developer org.

Please advise?

Hi All,

I am getting an error:-Invalid type: Database.SaveResult on Line 6.I have taken this code from the book and it is not running.

I understand that database is the namespace used here,Can I just mention Saveresult and Error class name without attaching database methods.

Can somebody please help?

public class fit
{
public void Passorfail(list<account>pass)
{

Database.SaveResult[] srList = Database.insert(pass, false);
// Iterate through each returned result
for (Database.SaveResult sr : srList) {
    if (sr.isSuccess()) {
        // Operation was successful, so get the ID of the record that was processed
        System.debug('Successfully inserted account. Account ID: ' + sr.getId());
    }
    else {
        // Operation failed, so get all errors               
        for(database.Error err : sr.getErrors()) {
            System.debug('The following error has occurred.');                   
            System.debug(err.getStatusCode() + ': ' + err.getMessage());
            System.debug('Account fields that affected this error: ' + err.getFields());
        }
    }
}


}
}
Hi All,


I have some basic question and after going throgh the salesforce docs I stil do not have answers to those questions.

1)What is the difference between Sobject and Object.?

Ans:-I could understand that sObject is a generic classs and object should be classes such as account,contact etc.However,I am not sure if I am  thinking correctly?

2)Are all standard classes such as Accounts and contacts etc derived from Sobject classs in salesforce.?

3) Can I know the root class in salesforc.I mean the class at the top if the heirarchy in salesorce.?

4)Is thier any diagram  available from salesorce regarding heirarchy of salesforce classses?

Can somebody please answer?


Thanks
Hi,I have taken below given code direclty from the book.This example is trying to access the account records and show in the visual force page.At no point of time I see in the debulogs ,my system.debug method in the getAccount() methid getting executed

Aren't the following lines suppose to execute getAccount() function?That is not hapening and yet I am able to see record information on the page.


i see constructor gettting executed and my save method getting executed.However,getAccount() is not getting executed.Can somebody please explain?.I am sure I am missing something.Please help

<apex:inputField value="{!Account.name}"/>
                <apex:inputField value="{!Account.phone}"/>
                <apex:inputField value="{!Account.industry}"/>



public class NewAndExistingController{
    public Account account{get;private set;}
    public NewAndExistingController()
        {
       
            ID id=ApexPages.currentPage().getParameters().get('id');       
            account=(id==null)? new account():[select Name,Phone,Industry from Account where id=:id];
           
            System.debug('This statement is whithin the construcotr'+account);
       
        }
       
        public account getAccount()
        {
       
        System.debug('The getAccount method before it returns account information to the visual force page is'+account);
            return account;
       
        }
        public Pagereference save()
        {
            try
                {
               
                System.debug('This line is before the account information has been upserted in the database'+account);
                     upsert(account);
                }
       
        catch(System.DMLException d)
            {
       
                Apexpages.AddMessages(d);
                return null;//
//              System.debug('therasied exception is'+d.message());
                   
        }
        return null;
   } 
   }




<apex:page controller="NewAndExistingController" tabstyle="Account">
    <apex:form >
        <apex:pageBlock mode="Edit">
            <apex:pageMessages />
            <apex:pageBlockSection >
                <apex:inputField value="{!Account.name}"/>
                <apex:inputField value="{!Account.phone}"/>
                <apex:inputField value="{!Account.industry}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi I am trying to understand below given code from teh visual force book.I am stuck at one place and i do not find information on that.

I am struggling to understand the lines underlined in the code:-

1) What does filterid signify here.I assume it should either be a method of the case class or some variable.I am not sure what it s.if it is one of these then where can I get information about them.

<apex:selectList value="{!filterId}" size="1">

2) I do  not understand {!listviewoptions} options .Can somebody please help?

<apex:selectOptions value="{!listviewoptions}"/>


<apex:page standardController="Case" recordSetvar="cases">
    <apex:pageBlock>
        <apex:form id="theForm">
            <apex:panelGrid columns="2">
                <apex:outputLabel value="View:"/>
                <apex:selectList value="{!filterId}" size="1">
                    <apex:actionSupport event="onchange" rerender="list"/>
                    <apex:selectOptions value="{!listviewoptions}"/>
                </apex:selectList>
            </apex:panelGrid>
            <apex:pageBlockSection>
                <apex:dataList var="c" value="{!cases}" id="list">
                {!c.subject}
                </apex:dataList>
            </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>
</apex:page>
Hi All,

I am using user pasword login authentication mechanism.I am doing this between two salesforce org.I have done the initial setup and I will be using Rest Api's.

I can see instance and  access token in the response .However ,I am not able to retrieve access token and Instance Url from the resposne.Can somebody please help me in accomplising that?I have Json format.





Static void login()
{

String ClientId='3MVG9xOCXq4ID1uGdZWMIUrMaRqoXtucMSraEOK1FxY.LQ78FdWYfStd7VGKBPCcS4OdjXHCmQ36ULHEzowxf';
String ClientSecret='5999022735349169870'; 
String username='xxxxxxxxxxxxxx;
String password='xxxxxxxxxxxxxxx;
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://login.salesforce.com/services/oauth2/token');
req.setBody('grant_type=password' +
            '&client_id=' + clientId +
            '&client_secret=' + clientSecret +
            '&username=' + EncodingUtil.urlEncode(username, 'UTF-8') +
            '&password=' + EncodingUtil.urlEncode(password, 'UTF-8'));
   

        Http http = new Http();
        HTTPResponse res = http.send(req);
       
        System.debug('BODY: '+res.getBody());
        System.debug('STATUS:'+res.getStatus());
        System.debug('STATUS_CODE:'+res.getStatusCode());
        //jsonObjectj=new JsonObject(res.getBody());
       
       
        //String accessToken = var.getValue('access_token').str;
        //System.debug('The value in teh access token is'+accessToken);
        //String instanceUrl = var.getValue('instance_url').str;
        //System.debug('instance URL'+instanceURL);
    

//        return new JSONObject(res.getBody());

    }

}
Hi ,


I am trying to connect salesforce to salesforc connection.Please help me.


Before I start doing anything I want to have some clarity on thw whole procedure
Following are the steps which I have in my mind.

1)I will start from trigger and in the trigger I am going to call the rest Api which i will develop in

another salesforce org and pass some paremeters to it.


I have some confusion about the redirect_uri paraemeter.I am not sure about it

What's gonna be the URI redirect_uri in my case.I have gone through the docs but still not sure.

Will redirect uri be the URL of source org from which I am calling the destination salesforce org Api's

Can somebody please explain?.I need to start soon as it is critical .Please help
Hi,

Below given is my code and it is not the complete  .

I have Reservation object and invoice .When somebody registers with us ,Invoice for that customer should be automatically created as child object.

I have lookup relationship beyween invoice and Reservation.

I want to get all the invoices associate with the particular registration.Since reservation__ is the paretn object and invoice is the child,therefore,i am trying the following query in the code.However,I get the folowing error.

Compile Error: Didn't understand relationship 'reservation__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 166 column 49

Can somebody please help?


list<Reservation__c>pc=new List<Reservation__c>([select id,(select id from reservation__r.invoice__c)from reservation__c where reservation__c in:samp])



 


trigger  reservation on reservarion__c(before delete
{
Map<id,invoice__c>must=new Map<id,invoice__c>();
list<invoice__c>ok=new list<invoice__c>();
If(Trigger.IsBefore & Trigger.IsDelete)
{
//Map<id,invoice__c>must=new Map<id,invoice__c>();
//list<invoice__c>ok=new list<invoice__c>();
Set<id> samp=new set<id>();
For(reservation__c r:trigger.old)
{

samp.add(r.id);
System.debug('The values in the record of delete trigger of the samp is##########################'+samp);
}

list<Reservation__c>pc=new List<Reservation__c>([select id,(select id from reservation__r.invoice__c)from reservation__c where reservation__c in:samp])
}
Hi ,I created trigger annd class in Eclipse and I wanted to test it in the saleforce UI.When I try to save Class in Eclipes.On the first line of code ,I see an x  red color checkbox which says

Multiple Markets at this line-
                                  -------------------File only saved locally,Not to the server

                                                                   --------------------------- save erro:-enitity is not org accessible.

The below given line is the first line and It gives me an error on this line,Saying 

Multiple Markets at this line-
                                  -------------------File only saved locally,Not to the server

                                                                   --------------------------- save erro:-enitity is not org accessible.

public class Reservation
{




Can somebody please help how to get rid of this error so that its gets saved to the salesforce from eclipse.?


Hi All,

I am working on the case trigger which will update an acount object.I just started and got the folowing error.Can somebody help?
In the below given code I am assigning accountid to the map and along with the acocuntid I am trying to the add the complete record in map.However,When I
do that I get the following error.I want to use map here so I will appreciate if somebody can correct this error.I do not want ot use set or list here.

Method does not exist or incorrect signature: [MAP<String,Case>].add(Id, SOBJECT:Case) at line 7 column 18

Trigger UpaatingPicklist on Case (After insert,after update)
{
    Map<String,case> cap=new Map<String,case>();
        for(case c:trigger.new)
            {
           
                 cap.add(c.accountid,c);
                
            }
}
Hi,

I have checkbox field on the contact object and i have to show the  count of the contacts on which this checkbox field have been checked on the account object..I am getting the followign error.I am not sure where I am going Wrong.Can somebody please help?

The error is:-Method does not exist or incorrect signature: [String].Size() at line 32 column 39


trigger BillingContactsCount on Contact (after Insert,after update) {
list<id> accountids=new list<id>();
for(contact c:trigger.new)
    {
        if(c.billingcontacts__c==true)
            {
         
           
            Accountids.add(c.accountid);
            System.debug('The account type checks are as follows'+Accountids.get(0));
           

            }
      
                 
    }

    list<contact> cc=[Select id,billingcontacts__c,Accountid from contact where accountid in:Accountids and billingcontacts__c=true];
    Map<ID,String>m=new map<ID,String>();
  
    for(Contact d:cc)
    {
   
     m.put(d.accountid,d.id);
    
   
    }
    for(Id ids:Accountids)
    {
   
    Account acc=new account(id=ids);
    acc.ContactCount__c=m.get(acc.id).Size();
   
    }
  }
Hi friends,

I have created a date field name last updated and based on changes in another field medical_Practioners.I am updating this last updated field automatically.

I am trying to create work flow and I selected formula evaluate to true and then inserted the following formula.

PRIORVALUE( Medical_Members__c )  <>  Medical_Members__c.

However,when I check syntax then I get the following error.

Error: Function PRIORVALUE may not be used in this type of formula

Can sombody tell me how to do that.?






Hi All,

Can we do cross object updation on standard objects using workflow rules.If we can ,can you please give me the link so that I can go through it.I know I can do that on custom objects having master detail relationship and I can use trigger to achieve it on stabdard objects.However,I want to know if we can use workflow rules on standard objects for cross updation.

Please guide and let me know the link 
Hi Guys,


Can any one of you please give me the link to download official admin guide from salesforce.Please help as soon as possible
Hi All,

I have two profiles one system administrator and another Standard Platform User.

I have created custom object widget1 and made it available to both the profiles.However,in the OWD's for the widget1 object I have specified  Private as the access level and after that I add record in the widget object and then I login as another user and I was hoping that  the other user will not be able to see this record as it's access level has been set as Private.However,when I login as another user then also I am able to see that record.


Can somebody please help?.Why is this hapening?.What is that I am missing?

Hi , I have gone through the apex guide .However,I still have one doubt ,I hope to get some answer here.

What is the difference between reading and writing using XMLReader class and Reading and Writing XML Using the DOM.

I feel that I can use any of the methods to accomplish my task of parsing the XML response.Is that correct?I am wrong please guide me with the proper explanation.

Convert lead to opportunity= help

Need to automatically convert leads to opportunity- how to add new APEX trigger and

trigger opptyCreationonConvert on Lead (before update) {     
List<Opportunity> o = new List<Opportunity>();

       for(Lead convertedLead: Trigger.new){
    if(convertedLead.IsConverted == TRUE && convertedLead.ConvertedOpportunityId == NULL){               
        o.add (new Opportunity(
        Name = convertedLead.Company,
        CloseDate = date.today()+90,
        AccountId = convertedLead.ConvertedAccountId,
        StageName = 'Booked Appointment'));
        }
    }
insert o;

}

HI All,

Whenever I write code for creating visual force pages .I have noticed lines get blurry and it is really tough to write code.I am not sure if others are having this problem or not.Anyonw with the same problem.I have tried writing code by enablling the developmet mode and also setup-----develop-----pages.
I have same problem .Is there anytihng that can be done.Please advice.

This is my personal developer org.

Please advise?

Hi everyone, this is my first post here but I've been reading quite a bit and have learned alot from these boards but have recently run into a road block that I cant seem to figure out.  Im hoping that someone might be able to point me in the right direction.

I need some help with Apex coding that would allow for a cross object field update from our org's custom object "Dispos" (appt results) to update corresponding fields in the opportunity object. I have created a custom object called "dispos" that allows our sales staff to enter appointment result information from the salesforce1 app. Our salesmen are subcontractors/1099 employess and we have force.com app licenses for them which allow them to be named users as well as having limited visibility into our org but they do not have access to the opportunity object (intentionally).

When a salesman runs an appointment that has been assigned to him, we require that he creates a new dispo record and fill in the blanks of the appointment results. Because of the limitations of the force.com app license they do not have visibility into the opportunity object that is the "master" location of new leads, appointment results and sold job information. What we are hoping to achieve through Apex is that when a new dispo is created and the proper opportunity record is referenced, that the details input by the salesmen are transferred into the corresponding fields of the opportunity.

I have tried to achieve this through a standard work flow rule and field update but I cant quite get this operation to work from custom objects to the opportunity. Ive contacted salesforce about this particular business process and have been told that it will only be possible through custom apex coding.  I am fairly flexible on how we achieve the desired result but my main goal to keep our office staff from having to reenter data that is already in the system in order to keep the opportunity records accurate and up to date.
Hi All,

I am getting an error:-Invalid type: Database.SaveResult on Line 6.I have taken this code from the book and it is not running.

I understand that database is the namespace used here,Can I just mention Saveresult and Error class name without attaching database methods.

Can somebody please help?

public class fit
{
public void Passorfail(list<account>pass)
{

Database.SaveResult[] srList = Database.insert(pass, false);
// Iterate through each returned result
for (Database.SaveResult sr : srList) {
    if (sr.isSuccess()) {
        // Operation was successful, so get the ID of the record that was processed
        System.debug('Successfully inserted account. Account ID: ' + sr.getId());
    }
    else {
        // Operation failed, so get all errors               
        for(database.Error err : sr.getErrors()) {
            System.debug('The following error has occurred.');                   
            System.debug(err.getStatusCode() + ': ' + err.getMessage());
            System.debug('Account fields that affected this error: ' + err.getFields());
        }
    }
}


}
}
Hi,

I may have this more complicated than it should be or there may be an easier way to do this.

I have a custom object (Invoice) that is a child to the Opportunity. We require the reps to look up an Invoice in Salesfore and attach the corresponding Opportunity to the custom lookup field Opportunity__c on the Invoice object

I wanted to make it as easy as possible for them, with as less clicks as possible. So I created a custom list button on the Invoice related list on the Opportunity page that brings them to a Visualforce page where they can search for an Invoice.
User-added image


Custom list button:  https://c.cs8.visual.force.com/apex/InvoiceHeaderSearch       I'd like to add this to the end to pass over the id (?id={!Opportunity.Id})


The visualforce page includes a search function for the Invoice and return results. It also includes an Edit link next to the results

Visualforce page:
My question is: Is it possible to pass the Opportunity ID over to the Visualforce page and then have it pass to the Edit link, so when the reps click on the Edit link, the Opportunity__c field is auto populated with the Opportunity ID?

Here is my visualforce page:
<apex:page standardController="Invoice_Header__c" extensions="Search" >

  <style type = "text/css">
    .Bld { font-weight:bold;}
  </style>
  
  <apex:form >
  
    <apex:pageblock title="Invoice" >
      <table align = "center" width = "100%" cellspacing = "5">
        <tr>
          <td class = "Bld">Invoice Name</td>
          <td><apex:inputText value="{!invName}" /></td>          
        </tr>
        <tr>
          <td align = "center" class = "Bld" colspan = "2"><apex:commandButton value="Search" action="{!find}"/></td> 
        </tr>        
      </table>
       
    </apex:pageblock>
        
    <apex:pageBlock title="Search Result">
      <apex:pageblockTable value="{!invList}" var="a">
        <apex:column >
        <apex:outputLink title="" value="/{!a.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
          <apex:outputlink value="https://cs8.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>
        </apex:column>
        <apex:column value="{!a.id}"/>
      </apex:pageBlockTable>     
    </apex:pageBlock>    
      
  </apex:form>
</apex:page>
               
User-added image Controller: public with sharing class invsearchcontroller {      public list <Invoice_Header__c> acc {get;set;}      public string searchstring {get;set;}      public invsearchcontroller(ApexPages.StandardSetController controller) {      }      public void search(){        string searchquery='select name, Invoice_Date__c, Total__c,Territory__c,id from Invoice_Header__c where name like \'%'+searchstring+'%\' Limit 20';        acc= Database.query(searchquery);      }      public void clear(){      acc.clear();      }    } Thanks
I have these 3 queries in the opening of my first page:

        List<Contact> lstContacts = [select id, MailingStreet, MailingCity, MailingState, MailingPostalCode, FirstName, LastName from contact LIMIT 50000];
        List<Lead> lstLeads = [select id, Street, City, State, PostalCode, FirstName, LastName from lead LIMIT 50000];
        List<Account> lstAccounts = [select id, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode from account LIMIT 50000];

I  have a user that is getting the following error when they try to open the application: Too many query rows: 50001

How is this possible if I have a limit on each of my queries?
I'm creating a custom object which will be a related list on Accounts.  The object is called Account Coverage.  It will act similar to account teams where you can list several account owners in the related list.  Unfortunately we can't customize Account Teams which is why we have to create this custom object.

Coverage fields were added to the account object and get updated based on users added to the Account Coverage object.  If a user is added to Account Coverage and the coverage checkbox is checked and your market unit meets the specific criteria, then your name is added to the corresponding account coverage fields on the account object.

Everything seems to be working ok, I'm just stuck on updating the coverage fields if the coverage checkbox is unchecked.  Any insight on how I can remove names from the coverage fields once the coverage checkbox is unchecked would be greatly appreciated.

Thanks!


public with sharing class AccountCoverageTriggerHandler {
	private boolean triggerIsExecuting = false;
   
    private integer batchSize = 0;
				
 	public boolean isTriggerContext{
        get { return triggerIsExecuting;}
    }

    public boolean isVisualforcePageContext{
        get { return !isTriggerContext;}
    }

    public boolean isWebServiceContext{
        get { return !isTriggerContext;}
    }

    public boolean isExecuteAnonymousContext{
        get { return !isTriggerContext;}
    }
    
  	public AccountCoverageTriggerHandler(boolean isExecuting, integer size){
    	triggerIsExecuting = isExecuting;
    	BatchSize = size;
  	}  	
  	
  	public void UpdateAccountCoverageInformation(list<Account_Coverage__c> Account_Coverage)
  	{
  		list<string> accts = new list<string>();
  		list<string> accountCoverage = new list<string>();
  		
  		for(Account_Coverage__c coverage : Account_Coverage)
  		{
  			accts.add(coverage.Account_Name__c);
  			accountCoverage.add(coverage.ID);
  		}
  		
  		list<Account> acct = [SELECT ID,Coverage_BPM__c,Coverage_Enterprise__c,Coverage_FGM__c
  										,Coverage_Global__c,Coverage_Inside_Sales__c,Coverage_IX__c
  										,Coverage_Portfolio__c,Coverage_Services__c
  										,(SELECT ID,Account_Name__c,Coverage__c,Account_Owner__r.FirstName,Account_Owner__r.LastName
  													,Account_Owner__c,Name,MU__c,BU__c,SR__c 
  													FROM Account_Coverage__r) 
  										FROM Account WHERE ID in : accts];										
  													
  		system.debug('accts = ' + acct);
  		system.debug('Account_Coverage = ' + Account_Coverage);
  		
  		for(Account accountForUpdate : acct)	
  		{
  			string coverageEnterprise = '';
  			string coverageIX = '';
  			string coverageBPM = '';
  			string coverageCorporateGlobal = '';
  			string coveragePortfolio = '';
  			string coverageFGM = '';
  			string coverageProfessionalServices = '';
  			string coverageMarketDevelopment = '';
  			
 			if(accountForUpdate.Account_Coverage__r == null ||  accountForUpdate.Account_Coverage__r.size() <1)
 			{
 				coverageEnterprise = '';
 				coverageIX = '';
  				coverageBPM = '';
  				coverageCorporateGlobal = '';
  				coveragePortfolio = '';
  				coverageFGM = '';
  				coverageProfessionalServices = '';
  				coverageMarketDevelopment = ''; 				
 			}
 			else
 			{
	  			for(Account_Coverage__c accCov : accountForUpdate.Account_Coverage__r)
	  			{
	  					system.debug('accCov' + accCov);
	
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('Enterprise'))
	  					{
	  						if(coverageEnterprise == '')
	  						{
	  							coverageEnterprise =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('ENT Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('ENT Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageEnterprise = coverageEnterprise + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('ENT Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('ENT Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					}
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('IX (Information Exchange)'))
	  					{
	  						if(coverageIX == '')
	  						{
	  							coverageIX =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('IX Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('IX Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageIX = coverageIX + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('IX Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('IX Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					} 
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('BPM'))
	  					{
	  						if(coverageBPM == '')
	  						{
	  							coverageBPM =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('BPM Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('BPM Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageBPM = coverageBPM + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('BPM Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('BPM Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					} 
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('Market Development'))
	  					{
	  						if(coverageMarketDevelopment == '')
	  						{
	  							coverageMarketDevelopment =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('MD Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('MD Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageMarketDevelopment = coverageMarketDevelopment + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('MD Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('MD Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					}
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('Professional Services'))
	  					{
	  						if(coverageProfessionalServices == '')
	  						{
	  							coverageProfessionalServices =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('PS Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('PS Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageProfessionalServices = coverageProfessionalServices + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('PS Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('PS Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					}	
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('Portfolio'))
	  					{
	  						if(coveragePortfolio == '')
	  						{
	  							coveragePortfolio =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('Portfolio Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('Portfolio Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coveragePortfolio = coveragePortfolio + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('Portfolio Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('Portfolio Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					}	
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('Corporate Global'))
	  					{
	  						if(coverageCorporateGlobal == '')
	  						{
	  							coverageCorporateGlobal =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('Corp Global Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('Corp Global Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageCorporateGlobal = coverageCorporateGlobal + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('Corp Global Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('Corp Global Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					}	  
	  					if(accCov.Coverage__c == true && accCov.MU__c.contains('FGM'))
	  					{
	  						if(coverageFGM == '')
	  						{
	  							coverageFGM =  accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	  							system.debug('FGM Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('FGM Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName);
	  						}
	  						else
	  						{
	  							coverageFGM = coverageFGM + accCov.Account_Owner__r.FirstName + ' ' +  accCov.Account_Owner__r.LastName  + ';';
	   							system.debug('FGM Account Owner First Name = '+ accCov.Account_Owner__r.FirstName);
	  							system.debug('FGM Account Owner Last Name Name = '+ accCov.Account_Owner__r.LastName); 							
	  						}
	  					}		  										  					  						  						  					
	  			}
 			}
  			
  			accountForUpdate.Coverage_Enterprise__c = coverageEnterprise;
  			accountForUpdate.Coverage_IX__c = coverageIX;
  			accountForUpdate.Coverage_BPM__c = coverageBPM;
  			accountForUpdate.Coverage_FGM__c = coverageFGM;
  			accountForUpdate.Coverage_Global__c = coverageCorporateGlobal;
  			accountForUpdate.Coverage_Inside_Sales__c = coverageMarketDevelopment;
  			accountForUpdate.Coverage_Portfolio__c = coveragePortfolio;
  			accountForUpdate.Coverage_Services__c = coverageProfessionalServices;
  		}
  		
  		if(acct.size()>0)
  		{
  			update acct;
  		}																	
  		
  	} 	
 	/*
  	public void onBeforeInsert(Account_Coverage__c[] newAccountCoverage){

    }
    */
    /*
    @future public static void onAfterInsertAsync(Set<ID> newAccountCoverageIDs){

    }
    */
 	
 	public void OnAfterInsert(Account_Coverage__c[] oldAccountCoverage, Account_Coverage__c[] updatedAccountCoverage, Map<ID, Account_Coverage__c> oldAccountCoverageMap) {
		UpdateAccountCoverageInformation(updatedAccountCoverage);  
 	}
	
 	/*
 	public void onBeforeUpdate(Account_Coverage__c[] oldAccountCoverage, Account_Coverage__c[] updatedAccountCoverage, Map<ID, Account_Coverage__c> oldAccountCoverageMap) {
		 
    }
	*/
	
    public void onAfterUpdate(Account_Coverage__c[] oldAccountCoverage, Account_Coverage__c[] updatedAccountCoverage, Map<ID, Account_Coverage__c> oldAccountCoverageMap) {
		UpdateAccountCoverageInformation(updatedAccountCoverage);
    }
	/*
    @future public static void onAfterUpdateAsync(Set<ID> updatedAccountCoverage){
		
    }
    */
    /*
    public void onBeforeDelete(Account_Coverage__c[] AccountCoverageToDelete, Map<ID, Account_Coverage__c> AccountCoverageMap){

    }
    */
    
    public void onAfterDelete(Account_Coverage__c[] deletedAccountCoverage, Map<ID, Account_Coverage__c> AccountCoverageMap){
		UpdateAccountCoverageInformation(deletedAccountCoverage); 
    }
    

    /*
    @future public static void onAfterDeleteAsync(Set<ID> deletedAccountCoverage){
        //to make this work like the on after delete you need to do a select statement into 
        //a list where ID in :deletedOpportunitySplits, this would recreate the deletedOpportunitySplits list
        //from there the code would work the same.
    }
    */

    /*
    public void onUndelete(Account_Coverage__c[] restoredAccountCoverage){

    }
    */

}


I am attempting to connect to an external application using Execute Anonymous in the Developer Console.
The application is using 2-Legged oAuth so I am encoding the signature in RSA-SHA1. Despite this, I seem to keep getting the result "Invalid Signature". Can anyone tell me if I am missing essential formatting in my code below for using oAuth?
Any help is greatly appreciated. I have also modified the Consumer Key and Private Key from thier true values, but maintained thier Size and special characters for a reference.

Http h = new Http();
String consumer_key='A1BF9UW7HS67STUOW8HUMKWODSJUOS';
                    
//Encoded PKCS8 Private Key
//Composed of Private Key Generated by OpenSSL
String secret_key='MIICXAIBAAKBgQDF9IiOjP0ZQcqGQ+Ut8K4Ug4vWe7' +
    'M6TRF+ruvVv1CtMOfZVV3kvtJPaNAD/bBs8W5wVFD+' +
    'tg+YhKL2nxkEKssdDNuyIOUa9OOQPbEBIjM7IJ8bRh' +
    '3kycneA0GPuNQIB3n5leCeCZtg56OR2WC8udc2FklQ' +
    'Jpvm0GWy+mvXC+DaewIDAQABAoGAce4+lgTROrMh88' +
    '0JCVugy1G/3UYfyxLeb26hVFPASmE635DRrLgbrjFL' +
    'qp4ZnvJwFa/1PxUWvso/3L9Or5ZNlmerHkdOdQhS3N' +
    'aUxDlB0RsCV7kwRVhaJbwsBKL07bYHqHCB3BE97xoN' +
    'Ak4ptsfEXYALeRnegSfpeq72fZGnYnECQQDrjPrfjH' +
    '9n5C60AfYgotQW6F52kHB6posgzltuTWh8UMaZUVD+' +
    'Td+mcDYIIlJnmG1qyL+v3Eu+CbBLDhY8HuXqNAbQCQ' +
    'RQkwEl1wGbrnyLeaKNH9t1yYmYwm93K+Vu9jAkEA1y' +
    'QCNs1A+IzbiUacbq1nzrstSzOdBCnLOeWBZRByqeYa' +
    'r6awJBANN5TcPYlli6/ME/a11Pjo6jZq5ZGaqR+nX6' +
    'JAeFJikDDPn/0yUicyV8d1OWJnZn8vxacvKIngsH6A' +
    'IgiM+iJMkiYnpFOtQScTj3S7PNcfNVAlz5mXuwvppA' +
    'pupU9KEU0h5iDRSXx/8UyUgHpcOWyKLewPp9FAnQyW' +
    'AF1+U0HSECQBVzu8CVaK7keNdOhHSgIsvCEdjzzA1P' +
    'd4uHbwGLObtCcxz2nwymQD4GZ8UMDZWLnX3/V2JbvQ' +
    'rlyKWHiMC6r5M=';

Long tmp=(System.now().getTime()/1000);

String encrypt_string = 'GET&https%3A%2F%2Fapi.xero.com%2Fapi.xro%2F2.0%2FContacts' +
                        '&oauth_consumer_key%3D' + consumer_key +
                        '%26oauth_nonce%3Dfef295f8188b8686fc922a66ec4fed2b' +
                        '%26oauth_signature_method%3DRSA-SHA1' +
                        '%26oauth_timestamp%3D' + tmp +
                        '%26oauth_token%3D' + consumer_key +
                        '%26oauth_version%3D1.0';


String algorithmName = 'RSA-SHA1';
String key =  secret_key;

// Decode the key from base64 to binary
Blob privateKey = EncodingUtil.base64Decode(key);
Blob input = Blob.valueOf(consumer_key);
Blob signature = Crypto.sign(algorithmName, input, privateKey);

String signatureA = EncodingUtil.base64Encode(signature);
String signatureB = EncodingUtil.urlEncode(signatureA, 'UTF-8');
System.debug('~~~ '+ signatureA);

// Try to get access token
HttpRequest req = new HttpRequest();
req.setEndpoint('https://api.xero.com/api.xro/2.0/Contacts' +
                        '?oauth_consumer_key=' + consumer_key +
                        '&oauth_nonce=fef295f8188b8686fc922a66ec4fed2b' +
                        '&oauth_signature=' + signatureB +
                        '&oauth_signature_method=RSA-SHA1' + 
                        '&oauth_timestamp=' + tmp +
                        '&oauth_token=' + consumer_key +               
                        '&oauth_version=1.0');
req.setMethod('GET');

// Send the request, and return a response
HttpResponse res = h.send(req);
System.debug('~~~ '+res.getBody());


trigger realtime1 on Contact (after insert)
{
set<id> set1=new set<id>();
list<account> aclist=new list<account>();
list<account> acnewlist=new list<account>();
list<Account> listac=new list<account>();
for(contact con:trigger.new)
   {
    set1.add(con.accountid);
   }
  acnewlist=[select id,name,billingaddress
                from account where id in:set1];
  for(contact con:trigger.new)
  {
    for(integer i=0;i<acnewlist.size();i++)
    {
     if(con.accountid==acnewlist[i].id)
     {
      con.account.sales_rep__c=con.department;
      aclist.add(con.account);
     }
   }
  }
update aclist;
}
I am writing a trigger to copy childs field value into parent field value. Let say operational_metrics__c is a parent object and contacts is its child object with lookup relation ship. Contact object has fields like lastname,driver_name__c,vehicle_type__C and operational_metrics__c has driver_name__c field. I need to copy driver_name__c in contact to driver_name__c in operational_metrics__c. I am trying like this

trigger opMetricsTrigger on Operational_Metrics__c (after insert,after update)
{
    Operational_Metrics__c[] op=null;
    Set<string> opIds = new Set<string>();
    Date d1,d2,cDate,pMont,cRegDate;  
    String dat;
    Contact con;
    decimal avg,nDays;
    Decimal tw;
    String convertedDate;
    String mTest,actionTaken,oAction;
    List<Operational_Metrics__c> c= new LIST<Operational_Metrics__c>();
    List<Operational_Metrics__c> cUpdate= new LIST<Operational_Metrics__c>();
    List<Operational_Metrics__c> cU= new LIST<Operational_Metrics__c>();
    private static boolean run = true;
    if(TriggerContextUtility.isFirstRun())
    {
     run=false;
     for (Operational_Metrics__c e : Trigger.new)
     {
         if(e.u_id__c != null)
         opIds.add(e.u_id__c );
     }
      
     List<Operational_Metrics__c> opm = [select Unique_Pile_ID__c,Surveyor__c,driver_name__C,u_id__C,Uid_number__c, Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c,No_of_Days_for_piling__c  from operational_metrics__c where u_id__c in :opIds];
     List<Operational_Metrics__c> uOpm = [select Unique_Pile_ID__c,Surveyor__c,u_id__C,Uid_number__c, Composting_Method__c,Pile_Monitoring_Date__c,Average_Temperature__c,Moisture_Test__c,Pile_Monitoring_Action_Taken__c,Other_Action__c,Pile_Input_Register_Date__c,Total_Waste_Input_on_the_Pile__c,Pile_Completion_Stage__c,Date_Pile_COmpleted__c,Curing_Batch_Register_Date__c,No_of_Days__c,No_of_Days_for_piling__c  from operational_metrics__c where u_id__c in :opIds and Pile_Completion_Stage__c='yes'];   
     
     List<Operational_Metrics__c> dName=[select Project__c,driver_name__c,Surveyor__c,vehicle_type__c,vehicle_number__c, (SELECT contact.LastName FROM Contacts__r)  from operational_metrics__c];
     for(Operational_Metrics__c d : dName)
     {
         if(d.Project__c=='Nalgonda')
         {
             for(contact cont:d.contacts__r)
             {
                 if(d.Vehicle_Type__c=='Tractor')
                 {
                      d.Driver_Name__c=cont.lastname;
                        // c.add(d);
                 }
             }
         }
         else if(d.Project__c=='Miryalaguda')
         {
             System.debug('prj2 '+d);
         }
     }
     for(Operational_Metrics__c ops : opm)
     {
  if(ops.Surveyor__c=='NLDA Supervisor')
        {
            ops.Project__c='Nalgonda';
        }
         else if(ops.Surveyor__c=='Araveli Nagaswara')
         {
             ops.project__C = 'Miryalaguda';
         }
        if(ops.Pile_Completion_Stage__c=='yes')
         {
           
             d1=ops.Date_Pile_COmpleted__c;
             convertedDate=String.valueOf(d1.day())+String.valueOf(d1.month());
             tw=ops.Total_Waste_Input_on_the_Pile__c;
             cDate=ops.Date_Pile_COmpleted__c;
         } 
         else if(ops.Curing_Batch_Register_Date__c!=null)
         {
             d2=ops.Curing_Batch_Register_Date__c;
             System.debug('records2 are '+ops);
         }
         else
         {
             avg=ops.Average_Temperature__c;
             mTest=ops.Moisture_Test__c;
             actionTaken=ops.Pile_Monitoring_Action_Taken__c;
             oAction=ops.Other_Action__c;
             pMont=ops.Pile_Monitoring_Date__c;
             cRegDate=ops.Curing_Batch_Register_Date__c;
         
          }
        if(d1!=null && d2!=null)
        {
           ops.No_of_Days_for_piling__c=d1.daysBetween(d2);
            nDays=ops.No_of_Days_for_piling__c;
           
            c.add(ops);
        }
     
     }
      for(Operational_Metrics__c u:uOpm)
      {
          u.Total_Waste_Input_on_the_Pile__c=tw;
          u.Average_Temperature__c=avg;
          u.Moisture_Test__c=mTest;
          u.Pile_Monitoring_Action_Taken__c=actionTaken;
          u.Other_Action__c=oAction;
          u.Pile_Monitoring_Date__c=pMont;
          u.Curing_Batch_Register_Date__c=cRegDate;
          u.No_of_Days_for_piling__c=nDays;
          u.Curing_Batch_Register_Date__c=d2;
       
          cUpdate.add(u);
      }
    
      TriggerContextUtility.setFirstRunFalse();
       update c;
       update cUpdate;
    }
}

But the child record value is not updating into parents record. could anyone help me out
Hi ,


I am trying to connect salesforce to salesforc connection.Please help me.


Before I start doing anything I want to have some clarity on thw whole procedure
Following are the steps which I have in my mind.

1)I will start from trigger and in the trigger I am going to call the rest Api which i will develop in

another salesforce org and pass some paremeters to it.


I have some confusion about the redirect_uri paraemeter.I am not sure about it

What's gonna be the URI redirect_uri in my case.I have gone through the docs but still not sure.

Will redirect uri be the URL of source org from which I am calling the destination salesforce org Api's

Can somebody please explain?.I need to start soon as it is critical .Please help
Hi,

In the below code, I am trying to send one header(Account) and multiple lines(Case). I am querying cases and adding it to a list(caseObj). The method which i am calling in the main class requires 2 parameters(String,List), so I am adding multiple cases in a list(ListLines).

The issue is that the list is getting the latest values and not the values of all the queried records. Please Help.

public class WMTestWebservice{
 
@future(callout = true)
    public static void WMTest(set<string> psoid){
   
        Account accObj=[select id,Name
                   
        from Account where Id=:psoid];
       
             
        List<Case> caseObj=[select id,Subject
                   
        from Case where Account.Id=:psoid];
             
      
    wmAppDev02AmHealthGeComSnehilPa.Snehil_Parts_Port  mainClass = new wmAppDev02AmHealthGeComSnehilPa.Snehil_Parts_Port ();
           
    wmAppDev02AmHealthGeComSnehilPa.Header header = new wmAppDev02AmHealthGeComSnehilPa.Header();
   
    wmAppDev02AmHealthGeComSnehilPa.Lines line = new wmAppDev02AmHealthGeComSnehilPa.Lines();
   
    List<wmAppDev02AmHealthGeComSnehilPa.Lines> ListLines = new wmAppDev02AmHealthGeComSnehilPa.Lines[150];
     
   
   
    mainClass.inputHttpHeaders_x = new Map<String, String>();

    String myCred1 = '******';
    String myCred2 = '******';
   
    Blob headerValue = Blob.valueOf(myCred1+':'+myCred2);
    String authorizationHeader = 'Basic ' +EncodingUtil.base64Encode(headerValue);
 
    mainClass.inputHttpHeaders_x.put('Authorization',authorizationHeader);
    mainClass.timeout_x=120000;
       
       
    header.name = accObj.Name;
    header.id   = accObj.id;
  
    integer i=0;
   
    for(Case cs: caseObj){ 
    
    line.EID    = cs.id;
    line.laptop = cs.Subject;
                   
    ListLines.add(i,line);// I am adding multiple cases in this list.
   
    system.debug('<<<<<ListLinesInsideLoop<<<<<'+ListLines);
   
    i = i+1;
      
     }
             
    system.debug('<<<<<ListLines<<<<<'+ListLines);   
    
   
    mainClass.ProcessPartOrder(header,ListLines);
       
   
   
    }
       
  }


Hi,

Below given is my code and it is not the complete  .

I have Reservation object and invoice .When somebody registers with us ,Invoice for that customer should be automatically created as child object.

I have lookup relationship beyween invoice and Reservation.

I want to get all the invoices associate with the particular registration.Since reservation__ is the paretn object and invoice is the child,therefore,i am trying the following query in the code.However,I get the folowing error.

Compile Error: Didn't understand relationship 'reservation__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 166 column 49

Can somebody please help?


list<Reservation__c>pc=new List<Reservation__c>([select id,(select id from reservation__r.invoice__c)from reservation__c where reservation__c in:samp])



 


trigger  reservation on reservarion__c(before delete
{
Map<id,invoice__c>must=new Map<id,invoice__c>();
list<invoice__c>ok=new list<invoice__c>();
If(Trigger.IsBefore & Trigger.IsDelete)
{
//Map<id,invoice__c>must=new Map<id,invoice__c>();
//list<invoice__c>ok=new list<invoice__c>();
Set<id> samp=new set<id>();
For(reservation__c r:trigger.old)
{

samp.add(r.id);
System.debug('The values in the record of delete trigger of the samp is##########################'+samp);
}

list<Reservation__c>pc=new List<Reservation__c>([select id,(select id from reservation__r.invoice__c)from reservation__c where reservation__c in:samp])
}

My Product has REST base webservices have data from different sources.

 

How can I code APEX to return results based on calling my REST services and returning the data and then show it in VisualSource?

 

Thanks