• ksnyder
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
Hi,

I am working on a formula field that would actually be generated as a report and pasted into HTML.

Basically, the scenario is this - if the Account, ABC Org has a value in Website, then I want it to display: ABC Org

If there is no website, then I just want it to display: ABC Org

So, I thought a formula field would work nicely for this:

IF(ISNULL( Website ) , Name + "
", "a href="" + Website + "">" + Name + "
"

But then I learned that formula fields do not want to display double-quotes. It keeps looking for my close parentheses after the double-set of quotes.

It didn't seem to want to display double-quotation marks under any circumstances.

Is there a workaround for this?

Many thanks.
Kim
Hello,

I took the 401 Developer class back in September and I recall the instructor saying something about how Roll-up Summary Fields can be used to enforce a 1:1 relationship between two objects. I have a custom object, Membership__c, which has a master-detail relationship to Accounts. I only want there to be one record in Membership__c for each Account.

Is there a way that I can put a RSF in Account, and if the RSF>1 then... (that's the part I can't recall). Would it be a workflow rule? I tried doing that, but then didn't see how I could enforce an error message.

Or since this is a 1:1, would best practices be to simply add those fields to Account (since we get 500 fields) - it just seemed like a lot of clutter since some of the Accounts aren't members.

Or would this have to be done with Apex code?

Many thanks,
Kim
Hello,

I have a trigger that updates a custom checkbox field in Accounts, "Workshop" (Workshop__c)  to "true" when a contact that is associated with the Account attends a workshop (yes, ideally, I will have an if statement to get this trigger to fire only once when the first attendance is logged ... ).

I have setup that trigger, tested it with data and it works fine:

Code:
trigger Workshop_Check on Workshop_Attendance__c (after insert) {
List<Account> updatedAccounts = new List<Account>();
Set<Id> OrgId = new Set<Id>();

for (Workshop_Attendance__c w : trigger.new)(
    OrgID.add(w.OrgID__c));
for (Account a : [SELECT id, Workshop__c FROM Account WHERE id IN :OrgID]){
    a.Workshop__c = true;
    updatedAccounts.add(a);
    }
update updatedAccounts;  
}

Now, after chasing my tail somewhat, I have the syntax seems to work for the test...however the test fails - the result when I run it shows that the expected value is false.

Code:
public class Check_Workshop {
    static testMethod void testCheck_Workshop() {


//test data - add new contact with account

Account acc = new Account(Name='Test Org');
insert acc;
Contact con = new Contact(AccountId=acc.id, Lastname = 'Doe', Firstname = 'Jane');
insert con;
Workshop_Attendance__c wkshp = new Workshop_Attendance__c(Contact_Name__c=con.id);
insert wkshp;

//confirm results to see that the workshop field is true for the corresponding account
Account[] accQuery = [SELECT Workshop__c FROM Account WHERE Id = :acc.id];
System.assertEquals(true, acc.Workshop__c);
    }
}

 Any ideas? Is it  not getting the right Account record?

Many thanks.





It would seem that the answer is no - though that doesn't make sense.

Basically, I am trying to write a before insert trigger to populate the Name (official) field of a custom object.  I have read a number of messages that are very close to this one - but not quite. Some folks recommend creating a VisualForce page, but I am trying to do it on a standard Salesforce form.

When I enter a new record, I get a message back saying "Invalid Data", "You Must Enter a Value". Now, this trigger works fine if I have it autopopulate a different, non-required field, it's fine. However, if I try to use it with the object's Name field or even another field that I have set to required, it fails. Does this sort of process not work , or am I mssing something?

Code:
trigger updateEnrollmentRecordName on Enrollment__c (before insert, after update) {
    List<Enrollment__c> updatedEnrollment = new List<Enrollment__c>();
    for (Enrollment__c e : trigger.new){
        e.Name = e.Enrollee_Name_Text__c + ' - ' + e.Program_Name__c + ' ' + e.Cycle__c + ' ' + e.Cycle_Year__c;
        updatedEnrollment.add(e);
  }     
 }

Many thanks.



Message Edited by ksnyder on 10-02-2008 03:07 PM
Hello,

I took the 401 Developer class back in September and I recall the instructor saying something about how Roll-up Summary Fields can be used to enforce a 1:1 relationship between two objects. I have a custom object, Membership__c, which has a master-detail relationship to Accounts. I only want there to be one record in Membership__c for each Account.

Is there a way that I can put a RSF in Account, and if the RSF>1 then... (that's the part I can't recall). Would it be a workflow rule? I tried doing that, but then didn't see how I could enforce an error message.

Or since this is a 1:1, would best practices be to simply add those fields to Account (since we get 500 fields) - it just seemed like a lot of clutter since some of the Accounts aren't members.

Or would this have to be done with Apex code?

Many thanks,
Kim
When I create an opportunity, I want to set name as now date time automatically without inputting anything.
at first I used trigger, but the name field is required. I can not save it without inputting name. but I don't want to input anything on name text box.
then I wrote some script code in a scontrol, which can get and set value in text box.
I can put this scontrol in contact detail page and get some value. but I can not put it in "New Contact" page.

Who can help me that?
Thanks
  • November 19, 2008
  • Like
  • 0
Hello,

I have a trigger that updates a custom checkbox field in Accounts, "Workshop" (Workshop__c)  to "true" when a contact that is associated with the Account attends a workshop (yes, ideally, I will have an if statement to get this trigger to fire only once when the first attendance is logged ... ).

I have setup that trigger, tested it with data and it works fine:

Code:
trigger Workshop_Check on Workshop_Attendance__c (after insert) {
List<Account> updatedAccounts = new List<Account>();
Set<Id> OrgId = new Set<Id>();

for (Workshop_Attendance__c w : trigger.new)(
    OrgID.add(w.OrgID__c));
for (Account a : [SELECT id, Workshop__c FROM Account WHERE id IN :OrgID]){
    a.Workshop__c = true;
    updatedAccounts.add(a);
    }
update updatedAccounts;  
}

Now, after chasing my tail somewhat, I have the syntax seems to work for the test...however the test fails - the result when I run it shows that the expected value is false.

Code:
public class Check_Workshop {
    static testMethod void testCheck_Workshop() {


//test data - add new contact with account

Account acc = new Account(Name='Test Org');
insert acc;
Contact con = new Contact(AccountId=acc.id, Lastname = 'Doe', Firstname = 'Jane');
insert con;
Workshop_Attendance__c wkshp = new Workshop_Attendance__c(Contact_Name__c=con.id);
insert wkshp;

//confirm results to see that the workshop field is true for the corresponding account
Account[] accQuery = [SELECT Workshop__c FROM Account WHERE Id = :acc.id];
System.assertEquals(true, acc.Workshop__c);
    }
}

 Any ideas? Is it  not getting the right Account record?

Many thanks.





It would seem that the answer is no - though that doesn't make sense.

Basically, I am trying to write a before insert trigger to populate the Name (official) field of a custom object.  I have read a number of messages that are very close to this one - but not quite. Some folks recommend creating a VisualForce page, but I am trying to do it on a standard Salesforce form.

When I enter a new record, I get a message back saying "Invalid Data", "You Must Enter a Value". Now, this trigger works fine if I have it autopopulate a different, non-required field, it's fine. However, if I try to use it with the object's Name field or even another field that I have set to required, it fails. Does this sort of process not work , or am I mssing something?

Code:
trigger updateEnrollmentRecordName on Enrollment__c (before insert, after update) {
    List<Enrollment__c> updatedEnrollment = new List<Enrollment__c>();
    for (Enrollment__c e : trigger.new){
        e.Name = e.Enrollee_Name_Text__c + ' - ' + e.Program_Name__c + ' ' + e.Cycle__c + ' ' + e.Cycle_Year__c;
        updatedEnrollment.add(e);
  }     
 }

Many thanks.



Message Edited by ksnyder on 10-02-2008 03:07 PM
Hello everybody, I'm pretty new with writing apex, and I'm trying to write a trigger which causes a checkbox to be checked or unchecked in my contacts object when a field is updated in another object (Legislature).  I'm not sure what is going wrong with the code I've written, but I've got the sneaking suspicion that it is entierly too simple.  I am trying to update all of the contacts from the state associated with the Legislature object that got updated.  Also, the Presently_in_Session__c field is a formula field that returns "TRUE" or "FALSE" depending on the current date, and is the field which will determine the state of the Legislature_in_Session__c checkbox on the contact object.  Anyway, here it is:

Code:
trigger Session_Check on Legislature__c (before update) {
List<Contact> updatedContacts = new List<Contact>();

for(Contact c : [SELECT id, Legislature_in_Session__c FROM contact WHERE Calculated_State_From_KeyPerson_Home_Bus__c = '{!Legislatures__c.State__c}']){
if('{!Legislature__c.Presently_In_Session__c}'=='TRUE'){
c.Legislature_in_Session__c = true;
}else{
c.Legislature_in_Session__c = false;
}
updatedContacts.add(c);
}
update updatedContacts;
}

I am not getting any errors, but it is not doing anything.  Any help would be greatly appreciated.



Message Edited by wpatters on 09-12-2008 01:15 PM

Message Edited by wpatters on 09-12-2008 01:34 PM