• bjzhu
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi,

 

I'm working on a VF email template and trying to output a couple related objects.

 

I want the recipient to be a Contact and I want to output variables from a "Buyer_Listing__c", and "Business_c" object, both of which are related lists for contact via a lookup field.

I also want to output a "Buyer_Listing_Categories__c" object that is master-detail with "Buyer_Listing__c" of that contact. Does anyone know how to accomplish this?

 

I looked around and found some suggestions but haven't gotten it to work:

 

 

-------------

 

 

<messaging:emailTemplate recipientType="Contact"
    subject="Test"
    relatedToType="Contact"
    replyTo="support@acme.com">
    
<messaging:htmlEmailBody >        
    <html>
        <body>
        <apex:repeat var="cy" value="{!relatedTo.Buyer_Listing__r}">
            <p>Asking Price: ${!cy.Listing_Price__c}.</p>
         </apex:repeat>
            <p><u>Business Identity and Location</u></p>
            <p>{!cy.Listed_Business__c}.</p>
         </apex:repeat>

 

Using apex:repeat seems like a really rough workaround, the other option is to change relatedToType = "Buyer_Listing_Categories__c", but then I can't find a way to get the "Business__c" object data.

  • June 05, 2012
  • Like
  • 0

Hi,

 

I'm working on a VF email template and trying to output a couple related objects.

 

I want the recipient to be a Contact and I want to output variables from a "Buyer_Listing__c", and "Business_c" object, both of which are related lists for contact via a lookup field.

I also want to output a "Buyer_Listing_Categories__c" object that is master-detail with "Buyer_Listing__c" of that contact. Does anyone know how to accomplish this?

 

I looked around and found some suggestions but haven't gotten it to work:

 

 

-------------

 

 

<messaging:emailTemplate recipientType="Contact"
    subject="Test"
    relatedToType="Contact"
    replyTo="support@acme.com">
    
<messaging:htmlEmailBody >        
    <html>
        <body>
        <apex:repeat var="cy" value="{!relatedTo.Buyer_Listing__r}">
            <p>Asking Price: ${!cy.Listing_Price__c}.</p>
         </apex:repeat>
            <p><u>Business Identity and Location</u></p>
            <p>{!cy.Listed_Business__c}.</p>
         </apex:repeat>

 

Using apex:repeat seems like a really rough workaround, the other option is to change relatedToType = "Buyer_Listing_Categories__c", but then I can't find a way to get the "Business__c" object data.

  • June 05, 2012
  • Like
  • 0

I'm writing a trigger that will automatically add sharing edit privileges for a contact to another user if that user is entered within a lookup field for that contact. I've been debugging a bit and it seems like the trigger is executing, but the sharing doesn't seem to be working properly.

 

If I set the org-wide sharing default to private, even if the trigger executes, I cannot view any contacts.

If I set the org-wide sharing default to public read only, if the trigger executes, I can edit contacts that i've shared, but not contacts that I haven't.

 

Any thoughts?

 

Here's the main code:

 

----------------------------

 

for (Contact contact : Trigger.new) {
// delete the old share
shareIdsToDelete.add(Trigger.oldMap.get(contact.id).id);
if (contact.Realtor__c != null) {
// create the new share with read/write access
ContactShare cs = new ContactShare();
cs.ContactAccessLevel = 'All';
cs.ContactId = contact.Id;

ID userId = [select id from User where Id =: contact.Realtor__c].id;

System.Debug('********USER ID**********************************************************');
System.Debug(userId);
cs.UserOrGroupId = userId;
System.Debug('********Realtor__c******');
System.Debug(contact.Realtor__c);

sharesToCreate.add(cs);
}
}
List<ContactShare> shares = [select id from ContactShare];
System.Debug('********SHARES PART 1**********************************************************');
System.Debug(shares.size());
// do the DML to delete shares
if (!shareIdsToDelete.isEmpty())
delete [select id from ContactShare where ContactId IN :shareIdsToDelete and RowCause = 'Manual'];

// do the DML to create shares
if (!sharesToCreate.isEmpty()) {
Database.SaveResult[] insertResults = Database.insert(sharesToCreate,false);

  • June 01, 2012
  • Like
  • 0

I'm writing a trigger that will automatically add sharing edit privileges for a contact to another user if that user is entered within a lookup field for that contact. I've been debugging a bit and it seems like the trigger is executing, but the sharing doesn't seem to be working properly.

 

If I set the org-wide sharing default to private, even if the trigger executes, I cannot view any contacts.

If I set the org-wide sharing default to public read only, if the trigger executes, I can edit contacts that i've shared, but not contacts that I haven't.

 

Any thoughts?

 

Here's the main code:

 

----------------------------

 

for (Contact contact : Trigger.new) {
// delete the old share
shareIdsToDelete.add(Trigger.oldMap.get(contact.id).id);
if (contact.Realtor__c != null) {
// create the new share with read/write access
ContactShare cs = new ContactShare();
cs.ContactAccessLevel = 'All';
cs.ContactId = contact.Id;

ID userId = [select id from User where Id =: contact.Realtor__c].id;

System.Debug('********USER ID**********************************************************');
System.Debug(userId);
cs.UserOrGroupId = userId;
System.Debug('********Realtor__c******');
System.Debug(contact.Realtor__c);

sharesToCreate.add(cs);
}
}
List<ContactShare> shares = [select id from ContactShare];
System.Debug('********SHARES PART 1**********************************************************');
System.Debug(shares.size());
// do the DML to delete shares
if (!shareIdsToDelete.isEmpty())
delete [select id from ContactShare where ContactId IN :shareIdsToDelete and RowCause = 'Manual'];

// do the DML to create shares
if (!sharesToCreate.isEmpty()) {
Database.SaveResult[] insertResults = Database.insert(sharesToCreate,false);

  • June 01, 2012
  • Like
  • 0

A couple of days ago I encountered an issue after running the apex test cases via the Apex Test Execution UI. Essentially, after trying to run all the test cases via the async functionality the Salesforce Org would have the Organization Administration Lock on and there was no way I could clear it.

 

As a result, any attempt to run another test case via the Apex Class UI would result in the message:

Organization Administration Locked

The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later.

Trying to save an Apex Class from Eclipse would result in the message:

Save error: Unable to perform save on all files: The changes you requested require > salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for > the previous action to finish, then try again later. (ALREADY_IN_PROCESS)

Initially I asked about it on Stack Overflow - Salesforce stuck in Organization Administration Locked state after using Apex Test Execution.

 

The response I got was that this is happening to other developers as well and that I should raise a support case, which I did (originally 07109567and then 07109712 was created separately by the support team for some reason unknown to me).

 

After about 30+ hours of not being able to develop or test in the locked sandbox orgs one of them was unlocked by support. I was told there was a known issue and to only run the test cases via the individual Apex Class UI. I should avoid running the tests via the Apex Test Execution UI or the Run All Tests button.

 

At this stage I guess I'd like to know:

  1. What exactly is the known issue and where can I find the status of it?
  2. In the event that one of the several orgs I work on experiences the known issue what can I tell/ask support that will help them unlock it faster?