• MaxiMize
  • NEWBIE
  • 50 Points
  • Member since 2006

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies

I'm trying to compare dates to determine the most recent date out of several records.  I was to get the record with the most recent date below, but that doesn't appear to be working.

 

tmpPostedDate = null
postedDate = null;

for (Sales_Invoice__c s : salesInvoiceList) {
                tmpPostedDate = s.Posting_Date__c;
                if (tmpPostedDate > postedDate) {
                                postedDate = tmpPostedDate;
                }
                else {
                                s.Posting_Date__c;
                }
}

Is there another way to get the most recent date when comparing across several records?

 

Thanks.

I'm hoping to deploy a trigger rather soon that will update a Custom Object Master/Detail relationship by putting the correct Account on the record.  It works on some inserts, and not on others.

 

Here's what should happen:  When the API sends over a collection of up to 200 Ordered Ad records, the trigger should fire (Before Insert) and associate the Ordered Ad with the proper Account.  If no account is in the system, it should assign it to the placeholder account, "Unknown Account".  For reasons I'm not clear about, it isn't associating some records with the right account.  I can manually create a record, and it *always* associates with the right account... On Batch insert, however, it's pretty hit and miss.

 

Would appreciate anyone taking a look at this and see if there's some obvious reason for this strange behaviour.

 

Thanks in advance.

 

 

trigger updateOrderedAdsAccount on Ordered_Ads__c (before insert) 
	
	{
        //Create record set of Account Numbers to tie to Contract Owners
        Set<String> acctnums = new Set<String>();
        MAP<String, Id> orderedAdsAcctRel = new Map<String, Id>();
        for(Ordered_Ads__c a:trigger.new)
        {
        	acctnums.add(a.Admarc_Number__c); 
        }
                
       //Iterate through Accounts and fine matches for ID based on Account Number
        for (Account u:[select id, AccountNumber from Account where AccountNumber != null AND AccountNumber in :acctnums limit 1])
        {
        	String acctnum = u.AccountNumber;
        	orderedAdsAcctRel.put(acctnum, u.id);
        }
           
        //Iterate through Accounts a and update according to user data from Map
        for (Ordered_Ads__c a:trigger.new)
        {
        	if (orderedAdsAcctRel.containsKey(a.Admarc_Number__c))
        	{
        		Id u1 = orderedAdsAcctRel.get(a.Admarc_Number__c);
        		a.Account__c = u1;
        	}
        	else
        	{
        		a.Account__c = '0014000000Efgve';
        	}
        }
    }

 

 

I have a trigger on a Custom Object (Ordered Ads).  The object is a Master/Detail with the Standard Object, "Account" (Account is the master). 

 

When inserting the Ordered Ads each day, I have a trigger that *should* associate the Ordered Ad record with the appropriate Account record based on AccountNumber.  However, it's not working.  When I attempt to enter a new record, I get an error message stating that I must enter a value in the Account__c field.  I would greatly appreciate any thoughts / advice on where I'm going wrong here...

 

 

trigger updateOrderedAdsAccount on Ordered_Ads__c (before insert) 
	
	{
        //Create record set of Account Numbers to tie to Ordered Ads
        Set<String> acctnums = new Set<String>();
        for(Ordered_Ads__c a:trigger.new)
        {
        	acctnums.add(a.Admarc_Number__c);               
        }
                
        //Create empty Maps to hold relationships. 
        MAP<String, Id> orderedAdsAcctRel = new Map<String, Id>();
       
        //Iterate through Accounts and find matches for ID based on Account Number
        for (Account u:[select id, AccountNumber from Account where External_Id__c != null AND External_Id__c in :acctnums limit 1])
        {
        	if(u.AccountNumber != null)
        	{
        		String acctnum = u.AccountNumber;
        		orderedAdsAcctRel.put(acctnum, u.id);
        	}
        	else
        	{
        		String acctnum = u.AccountNumber;
        		orderedAdsAcctRel.put(acctnum, '0014000000Ektmx');
        	}
        }
           
        //Iterate through Ordered Ads and update according to Account data from Map
        for (Ordered_Ads__c a:trigger.new)
        {
            Id u1 = orderedAdsAcctRel.get(a.Admarc_Number__c);
            a.Account__c = u1;
            
            if (a.Account__c = '')
            {
            	a.Account__c = '0014000000Ektmx';
            }
        }
    }

 

 

I do have a test case, and it passes the test case only when I select an existing account.  If I try to create a new account through the Test Case, I get the same error (Must supply a value for Account__c).

 

I have the trigger in my Sandbox, and it does work there.  The means for moving to Production was through the SFDC Deploy feature.

 

Again, I appreciate any advice on this.

 

Thanks.

I'm still pretty new to SSIS, but I've *almost* got things working.  I'm stuck on why I can't create an Account object (called, for example, Acct) as an Array of Accounts.  It continually errors out on that point, saying that the "Object reference not set to an instance of an object.  Here is the code for what I'm doing in that section.  If anyone has any ideas, I'd be most appreciative!


Dim Acct(200) As Account
Dim recCounter As Integer = 0      
      
'Assign values to Update Data
For recCounter = 0 To 200
       Acct(recCounter).Id = SoRec(recCounter).Id
Next
I'm almost there, but I have a problem... I can't see just how to create an sObject that contains the ID for an account and any fields that need to be updated.  Would appreciate anyone who might be able to point me in the right direction.
I'm having a small bit of trouble... I've read through the quick start guide, but I'm not able to complete the creation of the web service.  I'm using Visual Studio .NET 2005 (2.0.5).  I've created and downloaded the enterprise.wsdl file.  I am confused on the following points:

1.  HTTPconnection:  Is this simply "https://login.salesforce.com/"?  It does test successful, but that doesn't mean it's connecting to the right place.

2. If I use the above step and download the wsdl file, I get something that doesn't work.  Downloading and specifiying directly allows me to go on to the second step of specifying the input.

3.  On the INPUT tab, I am able to select SforceService  After selecting, however, I get an immediate error stating that "This version of the web services definition language (wsdl) is not supported."

I'm absolutely certain that I am missing something very basic here... I haven't touched SSIS in a couple of years, and then it was only for a training class.  Am I creating the project wrong?  Am I missing something else? 

Any help?  Point me towards a reference?  Anything at all?  Please??

I am trying to test an aggregate query in the Schema Explorer. Unfortunately I can't seem to get it to work. When I run the following query, I got 7 results back:

 

SELECT Current_Annual_Maintenance_Value__c FROM Asset

 

However, when I run the following query I get nothing:

 

SELECT sum(Current_Annual_Maintenance_Value__c) FROM Asset

 

Can anyone explain how to correctly do an aggregate function in a query to work? I can't get anything to work when I try Count() either. I just get an empty column of data with expr0 as the column name.

I'm hoping to deploy a trigger rather soon that will update a Custom Object Master/Detail relationship by putting the correct Account on the record.  It works on some inserts, and not on others.

 

Here's what should happen:  When the API sends over a collection of up to 200 Ordered Ad records, the trigger should fire (Before Insert) and associate the Ordered Ad with the proper Account.  If no account is in the system, it should assign it to the placeholder account, "Unknown Account".  For reasons I'm not clear about, it isn't associating some records with the right account.  I can manually create a record, and it *always* associates with the right account... On Batch insert, however, it's pretty hit and miss.

 

Would appreciate anyone taking a look at this and see if there's some obvious reason for this strange behaviour.

 

Thanks in advance.

 

 

trigger updateOrderedAdsAccount on Ordered_Ads__c (before insert) 
	
	{
        //Create record set of Account Numbers to tie to Contract Owners
        Set<String> acctnums = new Set<String>();
        MAP<String, Id> orderedAdsAcctRel = new Map<String, Id>();
        for(Ordered_Ads__c a:trigger.new)
        {
        	acctnums.add(a.Admarc_Number__c); 
        }
                
       //Iterate through Accounts and fine matches for ID based on Account Number
        for (Account u:[select id, AccountNumber from Account where AccountNumber != null AND AccountNumber in :acctnums limit 1])
        {
        	String acctnum = u.AccountNumber;
        	orderedAdsAcctRel.put(acctnum, u.id);
        }
           
        //Iterate through Accounts a and update according to user data from Map
        for (Ordered_Ads__c a:trigger.new)
        {
        	if (orderedAdsAcctRel.containsKey(a.Admarc_Number__c))
        	{
        		Id u1 = orderedAdsAcctRel.get(a.Admarc_Number__c);
        		a.Account__c = u1;
        	}
        	else
        	{
        		a.Account__c = '0014000000Efgve';
        	}
        }
    }

 

 

I have a trigger on a Custom Object (Ordered Ads).  The object is a Master/Detail with the Standard Object, "Account" (Account is the master). 

 

When inserting the Ordered Ads each day, I have a trigger that *should* associate the Ordered Ad record with the appropriate Account record based on AccountNumber.  However, it's not working.  When I attempt to enter a new record, I get an error message stating that I must enter a value in the Account__c field.  I would greatly appreciate any thoughts / advice on where I'm going wrong here...

 

 

trigger updateOrderedAdsAccount on Ordered_Ads__c (before insert) 
	
	{
        //Create record set of Account Numbers to tie to Ordered Ads
        Set<String> acctnums = new Set<String>();
        for(Ordered_Ads__c a:trigger.new)
        {
        	acctnums.add(a.Admarc_Number__c);               
        }
                
        //Create empty Maps to hold relationships. 
        MAP<String, Id> orderedAdsAcctRel = new Map<String, Id>();
       
        //Iterate through Accounts and find matches for ID based on Account Number
        for (Account u:[select id, AccountNumber from Account where External_Id__c != null AND External_Id__c in :acctnums limit 1])
        {
        	if(u.AccountNumber != null)
        	{
        		String acctnum = u.AccountNumber;
        		orderedAdsAcctRel.put(acctnum, u.id);
        	}
        	else
        	{
        		String acctnum = u.AccountNumber;
        		orderedAdsAcctRel.put(acctnum, '0014000000Ektmx');
        	}
        }
           
        //Iterate through Ordered Ads and update according to Account data from Map
        for (Ordered_Ads__c a:trigger.new)
        {
            Id u1 = orderedAdsAcctRel.get(a.Admarc_Number__c);
            a.Account__c = u1;
            
            if (a.Account__c = '')
            {
            	a.Account__c = '0014000000Ektmx';
            }
        }
    }

 

 

I do have a test case, and it passes the test case only when I select an existing account.  If I try to create a new account through the Test Case, I get the same error (Must supply a value for Account__c).

 

I have the trigger in my Sandbox, and it does work there.  The means for moving to Production was through the SFDC Deploy feature.

 

Again, I appreciate any advice on this.

 

Thanks.

I'm trying to compare dates to determine the most recent date out of several records.  I was to get the record with the most recent date below, but that doesn't appear to be working.

 

tmpPostedDate = null
postedDate = null;

for (Sales_Invoice__c s : salesInvoiceList) {
                tmpPostedDate = s.Posting_Date__c;
                if (tmpPostedDate > postedDate) {
                                postedDate = tmpPostedDate;
                }
                else {
                                s.Posting_Date__c;
                }
}

Is there another way to get the most recent date when comparing across several records?

 

Thanks.

Hi all,

 

I am testing some of my triggers and I realized that real data from salesforce can be used in testing.

Can I somehow avoid that?

I want to avoid using real data because some of my tests fail because uniques key, and I want just to test Insert data, without having to check first which key is not being used.

 

How can I do it?

 

Thanks in advance

Hello,

 

I am unable to add the field "Email Opt Out" (API name "HasOptedOutOfEmail") to our Lead page layout in our Sandbox environment.  The strange thing is, when i click "Edit Layout" and attempt to add "Email Opt Out" to the layout, it appears in the layout editing view as it should along with the rest of the fields, but when I save it, it does not show up in the actual layout.

 

This is causing problems during development because my orginization is using the Partner WSDL, and as such we can only access object fields that are in the page layout for that object.  So "Email Opt Out" does not exist as a valid field in the WSDL, and when I try to create or update a Lead with a value in the "HasOptedOutOfEmail" API field, I get a INVALID_FIELD_FOR_INSERT_UPDATE exception.

 

Any ideas, or anyone run into this before?  I would appreciate any help, except for just saying "well then just use the Enterprise client!" -- this is not feasible in our organization right now because our entire Salesforce library was written to use the Partner API.

 

Thank you!

SB

I'm still pretty new to SSIS, but I've *almost* got things working.  I'm stuck on why I can't create an Account object (called, for example, Acct) as an Array of Accounts.  It continually errors out on that point, saying that the "Object reference not set to an instance of an object.  Here is the code for what I'm doing in that section.  If anyone has any ideas, I'd be most appreciative!


Dim Acct(200) As Account
Dim recCounter As Integer = 0      
      
'Assign values to Update Data
For recCounter = 0 To 200
       Acct(recCounter).Id = SoRec(recCounter).Id
Next
I'm almost there, but I have a problem... I can't see just how to create an sObject that contains the ID for an account and any fields that need to be updated.  Would appreciate anyone who might be able to point me in the right direction.
Hi Everyone,
 
 

I'm having issue trying to add a web reference to my biztalk and .net projects using the enterprise web services API.

I'm trying to create a web reference to the following url ('https://www.salesforce.com/services/Soap/c/12.0') but I keep getting this error:

There was an error downloading 'https://www.salesforce.com/services/Soap/c/12.0'.

The request failed with HTTP status 405: GET not supported.

I would like to create the reference so I can't retrieve the WSDL and make a call to the QueryAll method. 

Am I missing something?  Did I have the right Url?

Waiting for your response.

Thanks,

Sheldon