• ag415
  • NEWBIE
  • 20 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hello,

I am trying to run a test class to test a new trigger I've written that deals with the contacts object. I already have a separate trigger written which deals with accounts, and I have a separate test class for that trigger which I already ran in the past. However, I noticed that whenver I run my contact trigger test class, it seems to be testing the wrong trigger? Every time I run it, the only trigger that shows up in the "overall code coverage" window is the old accounts trigger. I even went as far as backing up the accounts trigger and the accounts trigger test class and then deleting them from my sandbox altogether, and even now, despite this, every time I try to run the contacts trigger test class it still shows the name of the old accounts trigger in the overall code coverage window, with no mention of the contact trigger at all. Is this some kind of bug in the developer console?
  • August 13, 2014
  • Like
  • 0
Hello,

I originally posted this question in the Salesforce Answers Community, but I was told that it would be best to post this here instead.

I am working an Apex trigger that performs an action based on the condition that two fields equal a certain a value (or in this case, DON'T equal a certain value). One of the fields is a custom boolean field on the record that the trigger is firing for - which works fine - but the other is a field on a related record that is linked to that record via a lookup field.

The object the trigger is executing for is the Contacts object. I have an 'if' statement in the trigger that checks the value of the custom "Private__c" boolean field on the contact record as well as another custom boolean field (also called "Private__c") on the account record linked to the contact record via the Account lookup field.

Basically, I want my trigger to check if "Private__c" on the contact record and "Private__c" on the related account record are both false, and then execute some code if they are. Else, execute some different code.

So far, my code looks a little something like this:

for (Contact c : Trigger.new) {
    if(! c.Private__c && ! c.Account.Private__c) {
        "do stuff"
    } else {
        "do something else"
    }
}
But this doesn't seem to work, even though the developer console doesn't seem to complain about any unknown fields or other errors as I would expect it to if "c.Account.Private__c" wasn't a valid field. Am I missing something here? Is it not possible to reference fields belonging to the related record this way? And if so, what is the correct way to reference them so I can check their values in an 'if' statement?

I'd appreciate any help I can get on this one.

Thanks!
  • August 12, 2014
  • Like
  • 0

Hello,

 

I am new to the developer forums. I am not sure if this is the correct section to post this in, so please forgive me if this post is miscategorized.

 

I work for a non-profit ethnic media organization. We are currently using a very outdated and poorly-built CRM that also includes an ethnic media directory. We use the CRM to keep records of all of our partner media outlets and their associated contacts. We sell subscriptions to the ethnic media directory on our website.

 

The ethnic media directory grants subscribers read-only access to view certain records in the CRM (ethnic media outlets and their associated contacts). Directory subscribers register for an account through our website and are able to log in to the directory using that account through a web-based portal which is separate from our internal CRM login page.

 

We recently began building a new CRM using SalesForce. Our goal is to switch over from our old CRM to SalesForce. We have imported all of our records from the old system and are pretty much finished setting up the new CRM, but we have not yet built a replacement for our old ethnic media directory. I am curious to know if anyone has any suggestions on how to go about doing this.

 

I've read a few things about VisualForce and Apex, and I am curious to know if I could use these to build a new ethnic media directory that grants subscribers a form of limited access to certain records in our SalesForce org. The system would need to be able to handle registering and authenticating subscribers, providing read-only access to certain records and so on through a web-based portal interface.

 

We are currently using a free non-profit edition of SalesForce, so we are limited to 10 user licenses. The ethnic media directory would ideally use a single "API/read-only user" account to access SalesForce. Ideally, I would like for the directory to reference the Contacts object for registering and authenticating subscribers, as we could have a special contact record type for subscribers with an encrypted field to store their password and a date field to store their subscription expiration date.

 

I'm fairly new to SalesForce in general and I have no prior experience working with VisualForce, Apex, etc. I'd like to know if there's a way to do this with VisualForce/Apex and if so, how do I go about building it? Will I need to use PHP instead? Please let me know.

 

Thanks for taking the time to read and respond to my post.

 

  • August 08, 2013
  • Like
  • 0
Hello,

I am trying to run a test class to test a new trigger I've written that deals with the contacts object. I already have a separate trigger written which deals with accounts, and I have a separate test class for that trigger which I already ran in the past. However, I noticed that whenver I run my contact trigger test class, it seems to be testing the wrong trigger? Every time I run it, the only trigger that shows up in the "overall code coverage" window is the old accounts trigger. I even went as far as backing up the accounts trigger and the accounts trigger test class and then deleting them from my sandbox altogether, and even now, despite this, every time I try to run the contacts trigger test class it still shows the name of the old accounts trigger in the overall code coverage window, with no mention of the contact trigger at all. Is this some kind of bug in the developer console?
  • August 13, 2014
  • Like
  • 0
Hello,

I originally posted this question in the Salesforce Answers Community, but I was told that it would be best to post this here instead.

I am working an Apex trigger that performs an action based on the condition that two fields equal a certain a value (or in this case, DON'T equal a certain value). One of the fields is a custom boolean field on the record that the trigger is firing for - which works fine - but the other is a field on a related record that is linked to that record via a lookup field.

The object the trigger is executing for is the Contacts object. I have an 'if' statement in the trigger that checks the value of the custom "Private__c" boolean field on the contact record as well as another custom boolean field (also called "Private__c") on the account record linked to the contact record via the Account lookup field.

Basically, I want my trigger to check if "Private__c" on the contact record and "Private__c" on the related account record are both false, and then execute some code if they are. Else, execute some different code.

So far, my code looks a little something like this:

for (Contact c : Trigger.new) {
    if(! c.Private__c && ! c.Account.Private__c) {
        "do stuff"
    } else {
        "do something else"
    }
}
But this doesn't seem to work, even though the developer console doesn't seem to complain about any unknown fields or other errors as I would expect it to if "c.Account.Private__c" wasn't a valid field. Am I missing something here? Is it not possible to reference fields belonging to the related record this way? And if so, what is the correct way to reference them so I can check their values in an 'if' statement?

I'd appreciate any help I can get on this one.

Thanks!
  • August 12, 2014
  • Like
  • 0