• venturec
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies

I am attempting to use the DescribeSOBjects using the office toolkit vs. 4.0, and cannot seem to get this to work properly.

 

Does anyone have some good examples of how to use this method in the VBA editor?

 

Thanks.

 

Private Sub GetSObjects_Click()

    Dim Username As String
    Dim Password As String
    Username = "user@user.org"
    Password = "password"

    Dim sfSession As SForceSession4
    Set sfSession = New SForceSession4
    
    Dim dsr() As String
    If sfSession.Login(Username, Password) Then
        dsr = sfSession.DescribeSObjects( "Account")
    Else
        MsgBox "Invalid Login"
    End If

End Sub

 

When I run the above line I get an error saying Expected Function or Variable

 

Even when I change dsr = sfSession.DescribeSObjects( "Account") to

 

sfSession.DescribeSObjects( "Account"

 

I still get an error saying: Array passed to DescribeSObject needs to be of type VT_BSTR or BT_VARIANT.

 

Any help would be appreciated.

 

Thanks.

 

Does salesforce Apex support iterating over a map using a for loop?
Is there a way to stop a trigger from updating or inserting a record if certain parameters are not met?
 
I have an if statement inside a For loop, and am testing values. If the conditions are not met, I don't want the record updated or inserted.
 
Here's my code if you need it:
 

public class clsAbstractRatingTeam {

public static void updtEventID(Abstract_Rating_Team__c[] abstRT) {

List<Events__c> eventID = new List<Events__c>([select Id from Events__c where Current_Event__c = true]);

Integer lstSize = eventID.size();

if(lstSize == 1) {

String eID = eventID[0].Id;

for(Abstract_Rating_Team__c ar : abstRT) {

ar.Event_ID__c = eID;

}

} else {

// ? stop execution and do not continue.

}

}

}

 

Thanks for your help.

Looking for other resources that would lay out the structure of Apex, the syntax and the rules that govern execution.

I have found the Apex documentation to be less than satisfactory, and more of a dart board approach to documenting their product.
 
My hope is that I will find some better resources on building Apex Classes, utilizing Maps, Sets and Lists and what their purpose is.
 
Also, the SF Apex documentation is seriously lacking examples in writing testMethods.
 
Unsure who designed the document structure and how they were able to get away with this, but they need to know their structure is less than satisfactory and I am unable to piece together simple triggers using their documents.
 
  • Need more examples.
  • Need better explanations and what the purpose of each element is.
  • Better heirarchical structure in their documents with Higher Level Categories that funnel down to each items unique Attributes, Methods, Properties, etc.
 
If anyone has anything else, other than Salesforce, let me know.
 
Thanks.
Does salesforce Apex support iterating over a map using a for loop?

Let me preface this by saying that I am not all that experienced with Apex - I have dabbled enough to be dangerous, but do not have a robust understanding. Tried a search related to this issue and came up with nothing, but my apologies if I overlooked a previous related post.

 

Challenge with Contract Object:

 

I need a way to pull the Primary Contact information from the Related Contact list to the Contract.  I was able to build a trigger that brings the Primary Contact ID onto the Contract from the Related Contact Object, however when trying to populate the Contact Name affiliated with the Primary Contact ID I've hit a wall. Since the ContractContactRole object does not have a built in reference to the contact name I've got a bit more digging to do other than what I have existing - can't simply replicate the trigger and substitute a name field that doesn't exist on the object.

 

Need for the Primary Contact on the Contract: We have a WIL driven button that is designed to pull the Primary Contact name into a specified email template - in place for ease of use for the end user and a check to ensure the end user does not  select the wrong contact on the contract for this email. 

 

Right now the link is pulling the Contact ID, which obviously doesn't work to personalize the salutation in our email.  I need the Primary Contact ID on the Contract for the WIL to properly populate the email recipient, but I also need another field on the Contract that can serve as the merge field on the email template.

 

I tried a formula field, but no luck.  I think I have to go trigger route, but then it gets into an area of timing, which I have no idea how to solve.

 

 

Here is my Trigger for the Primary Contact ID:

 

 

trigger ShowContactID on Contract (before update) {
for (Contract c : Trigger.new) {
ContractContactRole contactRole =
[select ContactID from ContractContactRole where IsPrimary = true and ContractId = :c.id];

if (contactRole != null) {
c.Primary_Contact_ID__c = contactRole.ContactID;
}
}
}

 

 

 

 

Here is my attempt at a formula to populate the Contact Name:

 

 

IF(
Primary_Contact_ID__c = Contact_Lookup__r.Id ,
Contact_Lookup__r.FirstName ,
"Recipient"
)

 

 

 

 Thanks in advanced for helping me figure this out!

 

 

Does salesforce Apex support iterating over a map using a for loop?

Hi there - I work in the publishing industry where we use letter territories to determine which reps can call which companies.  (A - gets to call ABC company).  I have created custom fields on the campaigns page for each letter (A, B, C, D, so on and so forth) and I would like to - as reps make closed won sales, each letter to total up the total value won opportunities automatically for that letter.

 

i.e.


Alliance Company - $2490.50

ABC Company - $1549.50

Another Company - $449.50

 

 

The custom field A would tell me that the total value won opportunity for the particular campaign your on is...

 

A - $4,489.50

 

So to pull this it would be related to the "Campaign Name" and that particular campaigns total value won opportunities.

 

Is this possible?

Thanks.

I am working on my first apex trigger. The business process of this trigger is when the Technical contact (Technical_Contact__c)is selected from contacts via a lookup and a button is clicked, the phone number is added in the appropriate field (Technical_Phone__c)

 

I am receiving the following error:

 

Error: Compile Error: Invalid foreign key relationship: Contact.Manufacturing_Design_Sheet__c at line 21 column 10

 

Code

// When a new line item is added to an opportunity, this trigger copies the value of the
// associated product's color to the new record.
trigger TechContactTrigger on Manufacturing_Design_Sheet__c (before insert) {

    // For every Manufacturing Design Sheet record, add its associated contact entry
    // to a set so there are no duplicates.
    Set<Id> ContactIds = new Set<Id>();
    for (Manufacturing_Design_Sheet__c oli : Trigger.new)
        ContactIds.add(oli.Id);

    // Query the Contacts for their associated Phone Number and place the results
    // in a map.
    Map<Id, Contact> entries = new Map<Id, Contact>(
        [select contact.phone from contact
         where id in :ContactIds]);
        
    // Now use the map to set the appropriate Phone Number on every Manufacturing Design Sheet processed
    // by the trigger.
    for (Manufacturing_Design_Sheet__c oli : Trigger.new)
        oli.Technical_Phone__c = entries.get(oli.Technical_Contact__c).Manufacturing_Design_Sheet__c.Technical_phone__c; 
}

 

 

 

 

Thank you

 

Is there a way to stop a trigger from updating or inserting a record if certain parameters are not met?
 
I have an if statement inside a For loop, and am testing values. If the conditions are not met, I don't want the record updated or inserted.
 
Here's my code if you need it:
 

public class clsAbstractRatingTeam {

public static void updtEventID(Abstract_Rating_Team__c[] abstRT) {

List<Events__c> eventID = new List<Events__c>([select Id from Events__c where Current_Event__c = true]);

Integer lstSize = eventID.size();

if(lstSize == 1) {

String eID = eventID[0].Id;

for(Abstract_Rating_Team__c ar : abstRT) {

ar.Event_ID__c = eID;

}

} else {

// ? stop execution and do not continue.

}

}

}

 

Thanks for your help.