• Shikha Agashi
  • NEWBIE
  • 410 Points
  • Member since 2013
  • Global DataMart Inc

  • Chatter
    Feed
  • 13
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 91
    Replies
Failed to create createContainerMember for containerId=1dc28000000TnhRAAS: This container member belongs to a container that currently has an unfinished save request with deploymentId=1dr280000038Io9. You may not modify any members in this container until it completes.: Metadata Container ID
Hi,

Could someone tell me how i can get lead assignment rules when I am inserting new leads records with Jitterbit?

Thanks
Hi All,

I am creating a custom clone button on account. this is my VF page and controller. Button works fine but the issue is :
when i click clone the new record is created and saved.  I want when i click clone the page should remain in edit form and i should save it manually.

Please help.
 
<apex:page standardController="Account" extensions="AccountController" action="{!autoRun}">

  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have 
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>
</apex:page>

Here is my controller:
public with sharing class AccountController {

    public Account objAccount {get;set;}        
    public string AccountID;                        
   
    private Account objNewAccount;
     Map<String, Schema.SObjectField> mapAccountFields;
    
    public AccountController(ApexPages.StandardController controller) 
    {
      
     }
               
              public PageReference autoRun()
 {
        AccountID = ApexPages.currentPage().getParameters().get('id');
                
        if(AccountID != null)

        {        mapAccountFields = Schema.SObjectType.Account.fields.getMap() ;

                objNewAccount = [ select id,OwnerId,AccountId,Status__c from Account where id = :AccountID ] ;

                objAccount = objNewAccount.Account(false,true,false,false);

             insert objaccount;

        return new PageReference('/'+objAccount.id);
    }
return null;
}

}

 
Hi experts,

I am trying to build the following approval processes:

1) Record is submitted for approval to a Related user 
2) Related user has 24 hours to approve/reject.
3) If the Related user does not approve in 24 hours the request goes to User A. 
(User A is the same user for all approvals. User A is not a direct manager or delegated manager of Related User)

How can this be accomplished?
  • February 11, 2016
  • Like
  • 0
We have a use case were we need to have a custom button that would clone a custom object and all of its related records. I have created the button and it works great as the system administrator because that profile has access to the fields but when I log in as one of the other users I get an error because they dont have access to the fields. For security reasons we dont want to give them access to the fields but we want them to be able to clone the existing record. So what we would need is to have this button run as a system administrator. Is that possible? 

 
Hello,

I have 3 lookups (users) on the page.
I want to send email to theses users once the record is saved.

what are steps to implement
  • February 10, 2016
  • Like
  • 0
I am fairly new to Apex and am having a very difficult time trying to pass my trigger beyond 27%.

My trigger is as follows:
 
trigger LicenseDownloads on Account (after update) {

    for(Account acc:Trigger.new){
        Account oldAcc=Trigger.oldMap.get(acc.Id);
        if(oldAcc.License_Downloads__c!=acc.License_Downloads__c)
            {
                List<Contact>children=[SELECT Id,AccountId,Licensing_Downloads__c from Contact where AccountId = :acc.Id];
                List<Contact>newids=new List<Contact>();
                
                for(Contact con:children){
                    if(con.Licensing_Downloads__c!=acc.License_Downloads__c){
                        con.Licensing_Downloads__c=acc.License_Downloads__c;
                    newids.add(con);
                    }
                }
                if(newids.isEmpty()==false){
                    update newids;
                }
            }
    }
}

My test class is as follows:
 
@IsTest
public class RelationshipTypesInsert_Test {

    public testMethod static void contactInsertion() {
        Account acct = new Account(name='Apex Test Account',BillingState='Oregon',BillingCountry='United States');
        insert acct;

        // Consider setting some address fields as required by copyAddressFields
        Contact c = new Contact(AccountId=acct.Id, lastname='testing', firstname='apex');
        insert c;

        //Make some assertions based on the results of the copyAddressFields call
        
        List<Account> accountsToUpdate = new List<Account>();
        for(Account a : [SELECT Id,Name,Technology_Partner_Tier__c,Account_Status__c,Channel_Partner__c FROM Account WHERE Name = 'Apex test Account']){
            if(a.Account_Status__c == 'Inactive'){
                   a.Technology_Partner_Tier__c = 'Ecosystem';
                   a.Account_Status__c= 'Active';
                   a.Channel_Partner__c= 'Access';
                /** Here put update actions **/
                accountsToUpdate.add(a); 
            }
        }
        update accountsToUpdate;
           
    }

    public testMethod static void contactInsertionFails() {
        Account acct = new Account(name='test account');
        insert acct;

        // Set some fields that will cause an Exception in copyAddressFields
        Contact c = new Contact(AccountId=acct.Id, lastname='testing', firstname='apex', email='apex.testing@elementaltechonlogies.com');
        insert c;

        //Make some assertions that errors were added to the Contact

    }

    public testMethod static void bulkifedInsertaion() {
        Account acct = new Account(name='test account',BillingState='Oregon',BillingCountry='United States',Technology_Partner_Tier__c='Ecosystem',Account_Status__c='Active',Channel_Partner__c='Access');
        insert acct;

        Contact[] contactsToCreate = new Contact[]{};

        for(Integer x=0; x<200;x++){
            Contact ct = new Contact(AccountId=acct.Id,lastname='testing',firstname='apex',email='apex.testing'+x+'@elementaltechnologies.com');
            contactsToCreate.add(ct);
        }

        Test.startTest();
        insert contactsToCreate;
        Test.stopTest();   
    }
}

Anyone have any ideas?
Hi,

I have person accounts created in my org and i need to give them the ability to self-register in our community. The problem is that they can´t register because of their existing email.
I only can register new users as person accounts with diferent emails and usernames.

How can i link a new user with his/her existing persoun account?

thanks!
I have problem that I am struggling with. I need to update a NEW Child object with data from the parent.  Let me explain.

 OLD DATA MODEL
Account object  -  Account Name,  FieldA, Field B, etc

NEW DATA MODEL
Account Object  - Account Name
Channel Object (lookup relationship from Channel to Account) -  FieldA, FieldB

 FieldA from Account needs to be its own record in Channel

This is what it should look like in New Data Model:

Account  - Account Name
Channel - FieldA
Channel - FieldB
Channel - FieldC

I believe I don't need to use External IDs as I have read in previous posts, but I am confused to the correct way to set this up.
Hi,

Pls let me know, the error with the following code. In the VF page , the headers are not displaying.

<apex:page controller="BulkDeleteSobject2_Controller" showHeader="true" sidebar="true">
    <apex:sectionHeader title="BulkDelete" subtitle="SObject"/>
    <apex:form >
        <apex:pageBlock id="theBlock">
            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Delete Selected" action="{!DeleteSelected}" onclick="if(!confirm('Are you sure?')) return false;"/>
            </apex:pageBlockButtons>
        <apex:pageMessages />
            <apex:pageBlockSection columns="1">    
                <apex:selectList size="1" value="{!SelectedObject}" id="objects">
                    <apex:selectOptions value="{!sObjectList}" />
                    <apex:actionSupport event="onchange" action="{!executeSelect}" reRender="theBlock"/>
                    </apex:selectList>
                    <apex:pageBlockTable value="{!WrapperList}" var="item" id="records">
                        <apex:column style="width:100px;">
                            <apex:facet name="Header">
                                <apex:outputText value="Delete"/>
                            </apex:facet>
                            <apex:inputCheckbox value="{!item.DeleteThis}"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="Header">
                                <apex:outputText value="Name/Id"/>
                            </apex:facet>
                            <apex:outputText value="{!item.Name}" rendered="{!HasName == true}"/>
                            <apex:outputText value="{!item.sObj.Id}" rendered="{!HasName == false}"/>
                        </apex:column>
                    </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi Community,

I am trying to write a trigger that will update a field when the value of another field goes up or down by 10%. So I set the initial value of the field equal to the second field but from that point I would like the first field to stay the same until the value of the second field increases or decreases by 10 percent. 

I was able to get the field to copy but right now it is updating for every value change of the second field. Any help would be appreciated. I am posting the code below. 
 
trigger updateMK on Brief__c (before update, before insert) {

    

     
     
     for (Brief__c  brf : trigger.new){
     
        if (brf.Media_Kit_Needed__c == null){
        brf.Media_Kit_Needed__c = integer.valueof(brf.List_Size_Updated_Monthly__c);
     }
     
        else if (brf.Media_Kit_Needed__c <= (.10 * integer.valueof(brf.List_Size_Updated_Monthly__c)) + integer.valueof(brf.List_Size_Updated_Monthly__c)){
        brf.Media_Kit_Needed__c = integer.valueof(brf.List_Size_Updated_Monthly__c);
        }
        
        else if (brf.Media_Kit_Needed__c >= (.10 * integer.valueof(brf.List_Size_Updated_Monthly__c)) + integer.valueof(brf.List_Size_Updated_Monthly__c)){
        brf.Media_Kit_Needed__c = integer.valueof(brf.List_Size_Updated_Monthly__c);
        }
        
        else{
        brf.Media_Kit_Needed__c = brf.Media_Kit_Needed__c;
        
        }

     
     }

}

 
Hello,

I have created a report with type "Accounts with Activities" and have shared it to a public group.
All of them see different results..

The difference between the users is that, they belong to Different roles in the same hierarchy, and only one of the guy belong to diferent profile...

When i check the object permission for activity and account, it say that, Account is private and activities is controlled by Parent..

What is the Actual reason that, when the people see the report they all see different data..

thank you
  • January 29, 2016
  • Like
  • 0
Hi,

I am trying to add one Vf page on another Vf page. this is my page. 
<apex:page standardController="Account" extensions="Accountsextension" >
   
  
      
      <apex:pageBlock title="Account History" id="Account_History">
      <apex:pageBlockTable value="{!acchistlist}" var="accounthistory" rows="1000">
         <apex:column value="{!accounthistory.createddate}"/>
         <apex:column value="{!accounthistory.createdby.name}"/>
         <apex:column value="{!accountHistory.field}"/>
         <apex:column value="{!accounthistory.oldvalue}"/>
         <apex:column value="{!accounthistory.newvalue}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
    
    
    
</apex:page>

 i want to add another VF page called "Value" on this with this size

Height (pixels): 50
Width(pixels): 100%

Please help.



 
trigger EventTrigger on Event (before Insert, before update) {
        public static String communityId=Network.getNetworkId();
        
        if(trigger.isInsert){
            if(communityID!=null){ 
                String CommunityName=ConnectApi.Communities.getCommunity(communityId).name;
                //Update public calendar events for HR4HR community
                if(CommunityName=='HR4HR'){
                   publicCalendar__c pc = [SELECT ID__c FROM publiccalendar__c WHERE Name=: 'HR4HR Community Calendar'];
                   
                   for(Event e:trigger.new){
                       e.OwnerID=pc.ID__c;
                   }
                }
                
                //Update public calendar events for Tech Exchange community
                if(CommunityName=='TechExchange'){
                   publicCalendar__c pc = [SELECT ID__c FROM publiccalendar__c WHERE Name=: 'TechExchange Community Calendar'];
                   for(Event e:trigger.new){
                       e.OwnerID=pc.ID__c;
                   }
                }
            }
        }
        
        if(trigger.isUpdate){
           if(CommunityID!=null){
                for(Event e:trigger.New){
                    if(!(Trigger.OldMap.get(e.id).ownerId==e.ownerId)){
                        e.ownerID.addError('Assigned To field cannot be edited');
                    }    
                }
                
               
            }
            
        }

}

Above is my class and below is my test class.
 
@isTest(seeallData=true)
 public class EventTriggerTest{
  
  
  public static testMethod void testEventTrigger(){
        Network community;
        String communityId;   
        
        Id currentUserId = UserInfo.getUserId();    
        User usr = [select id,Name from User where id =: currentUserId]; 
        
   
     system.runAs(usr){
    community = [SELECT id, Name,OptionsReputationEnabled FROM Network where name =: 'TechExchange'];
        communityId = community.id;
     
    system.debug('Test User Inside Network'+network.getnetworkid());
       
      Event eve = new Event(
            // OwnerId= usr.Id,
             ActivityDate=system.today(),
             StartDateTime=system.now().addhours(35),
             EndDateTime=system.now().addhours(36),
             Subject='Test',
             Description='Testing the event controller'
                               );
      insert eve;
      
      Event e = [Select id, Subject from Event where id=:eve.id];
       
       System.assertEquals('Test', e.subject);
       e.subject='New';
       update e;
       
         
    }

     
  
  }
   
 
  

 }

 
We built custom web-to-case form. When a user fills information in that form, we want that on submission, we should programtically retrieve User's ID(window Id), user email, Browser information, computer name without user entering any of this information. Is this possible? if so, how can we achieve this? 

I tried using HTML/JavaScript to retrieve browser information but it is not that helpful. i want very specific information it say user is using IE ver 11.
 
trigger EventTrigger on Event (before Insert, before update) {
        public static String communityId=Network.getNetworkId();
        
        if(trigger.isInsert){
            if(communityID!=null){ 
                String CommunityName=ConnectApi.Communities.getCommunity(communityId).name;
                //Update public calendar events for HR4HR community
                if(CommunityName=='HR4HR'){
                   publicCalendar__c pc = [SELECT ID__c FROM publiccalendar__c WHERE Name=: 'HR4HR Community Calendar'];
                   
                   for(Event e:trigger.new){
                       e.OwnerID=pc.ID__c;
                   }
                }
                
                //Update public calendar events for Tech Exchange community
                if(CommunityName=='TechExchange'){
                   publicCalendar__c pc = [SELECT ID__c FROM publiccalendar__c WHERE Name=: 'TechExchange Community Calendar'];
                   for(Event e:trigger.new){
                       e.OwnerID=pc.ID__c;
                   }
                }
            }
        }
        
        if(trigger.isUpdate){
           if(CommunityID!=null){
                for(Event e:trigger.New){
                    if(!(Trigger.OldMap.get(e.id).ownerId==e.ownerId)){
                        e.ownerID.addError('Assigned To field cannot be edited');
                    }    
                }
                
               
            }
            
        }

}

Above is my class and below is my test class.
 
@isTest(seeallData=true)
 public class EventTriggerTest{
  
  
  public static testMethod void testEventTrigger(){
        Network community;
        String communityId;   
        
        Id currentUserId = UserInfo.getUserId();    
        User usr = [select id,Name from User where id =: currentUserId]; 
        
   
     system.runAs(usr){
    community = [SELECT id, Name,OptionsReputationEnabled FROM Network where name =: 'TechExchange'];
        communityId = community.id;
     
    system.debug('Test User Inside Network'+network.getnetworkid());
       
      Event eve = new Event(
            // OwnerId= usr.Id,
             ActivityDate=system.today(),
             StartDateTime=system.now().addhours(35),
             EndDateTime=system.now().addhours(36),
             Subject='Test',
             Description='Testing the event controller'
                               );
      insert eve;
      
      Event e = [Select id, Subject from Event where id=:eve.id];
       
       System.assertEquals('Test', e.subject);
       e.subject='New';
       update e;
       
         
    }

     
  
  }
   
 
  

 }

 
trigger AccountDuplicateTrigger on Account (before insert, before update) {
    //Create map of existing person accounts that don't have a externalID
	map<Id, Account> existingAccountMap = new Map<ID, Account>([Select ID, Name, externalID__c
                                                                FROM Account 
                                                                WHERE isPersonAccount=True AND externalID__c = Null]);
    //For new trigger accounts check if Name exists in existingAccountmap
    for(Account a : trigger.new) {
        map<ID, Account>newAccountMap = new Map<ID, Account>([SELECT ID, Name, externalID__c FROM Account
                                                                 WHERE ID IN :trigger.newMap.keySet()]);
    //If new account name matches an existing account then put UUID in the existing account
        if(a.name = existingAccountMap.get(a.ID).Name)
        {
          .........
        }
    
    }
}

We have an integration with a legacy system and we use an Unique ExternalID to send personAccount upserts back and forth between salesforce and the legacy system using JItterbit.
However, that externalID is provided by the legacy system, When a new record is created in Salesforce it is sent to the legacy system where it gets the Unique ExternalID. Problem is on the way back to Salesforce since the ExternalID isn't already on the Account, Jitterbit creates a new duplicate account. I was workign on the code above but not sure if it will get me what i'm trying to accomplish.
Failed to create createContainerMember for containerId=1dc28000000TnhRAAS: This container member belongs to a container that currently has an unfinished save request with deploymentId=1dr280000038Io9. You may not modify any members in this container until it completes.: Metadata Container ID
Hi,

Could someone tell me how i can get lead assignment rules when I am inserting new leads records with Jitterbit?

Thanks
I have a batch class that runs once a day to send me emails.
global class getCreatedLeadsSummary implements Database.Batchable<AggregateResult>, Database.Stateful {
    public string leadSummary;
    global Iterable<AggregateResult> start(Database.batchableContext info){
        // just instantiate the new iterable here and return
        return new AggregateResultIterable();
    }

    global void execute(Database.BatchableContext BC, List<AggregateResult> scope)
    {
        try
        {
            leadSummary = '<table bgcolor="silver" border="2" cellpadding="2"><tr><td><b>Lead Source</b></td><td><b>Count</b></td></tr>';
            for(AggregateResult ar: scope)
            {
                string src = (string) ar.get('LeadSource');
                Integer cnt = (Integer) ar.get('cnt');
                leadSummary = leadSummary + '<tr><td>' + src + '</td><td>'+ cnt.format() +'</td></tr>';
            }
            leadSummary = leadSummary + '</table>';            
        }
        catch(Exception ex)
        {
            System.Debug('Some Exception >'+ ex.getMessage());
        }
    }

    global void finish(Database.BatchableContext BC)
    {
        // Get the AsyncApexJob using JobId 
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email, ExtendedStatus   
                            FROM AsyncApexJob 
                            WHERE Id = :BC.getJobId()];  
                                    
        if(a.Status == 'Completed')           
            utilMail.sendNotificationMail('Lead Summary Job Result',a,leadSummary);   
        else
            utilMail.sendNotificationMail('Job Did not Complete!',a,'Failure');   
    }   

    global class AggregateResultIterable implements Iterable<AggregateResult> {
        global Iterator<AggregateResult> Iterator(){
            return new AggregateResultIterator();
       }
    }

    global class AggregateResultIterator implements Iterator<AggregateResult> {
        AggregateResult [] results {get;set;}
        Integer index {get; set;} 

        global AggregateResultIterator() {
            index = 0;
            String query = 'Select COUNT(Id) cnt, LeadSource From Lead WHERE CreatedDate = YESTERDAY GROUP BY LeadSource';
            results = Database.query(query);            
        } 
        
        global boolean hasNext(){ 
           return results != null && !results.isEmpty() && index < results.size(); 
        }    
        
        global AggregateResult next(){ 
            return results[index++];            
        }       
    }    
}

This is my test metohd I created.
 
static testmethod void testmethod1() {
            
            List<Lead> allLeads = new List<Lead>();
            for(integer i =0; i< 199; i++)
            {
                            Lead l = new Lead();
                            l.FirstName = 'TEST ' + i.format();
                            l.LastName = 'Lead';
                            l.Lease_Amount__c = 240;
                            l.LeadSource='2055 - Website';
                            l.Company = 'Testing Batch Jobs';   
                            l.Title = 'Dr';
                            l.Phone='5556667777';
                            allLeads.Add(l);
            }
       
       insert allLeads;

       Test.startTest();
       Database.executeBatch(new getCreatedLeadsSummary());     
       Test.stopTest();

       Integer i = [SELECT COUNT() FROM Lead WHERE CreatedDate=Today];
       System.Debug(i);       
       System.assertEquals(i, 199);
    }
After executing this test method, my coverage is at 56% (17/30) lines. So I found that the execute method is not being covered. How can I cover the execute method in my test class and attempt to reach 100% coverage?
 
When using the Data Loader to try and mass delete 1,200 contacts, I'm getting an "Invalid Record ID" for every single record, but the input csv file only has the ID for the contact which I have mapped.  Does anyone know why I would be getting this error and how to overcome it?
Hi All,

I am creating a custom clone button on account. this is my VF page and controller. Button works fine but the issue is :
when i click clone the new record is created and saved.  I want when i click clone the page should remain in edit form and i should save it manually.

Please help.
 
<apex:page standardController="Account" extensions="AccountController" action="{!autoRun}">

  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have 
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>
</apex:page>

Here is my controller:
public with sharing class AccountController {

    public Account objAccount {get;set;}        
    public string AccountID;                        
   
    private Account objNewAccount;
     Map<String, Schema.SObjectField> mapAccountFields;
    
    public AccountController(ApexPages.StandardController controller) 
    {
      
     }
               
              public PageReference autoRun()
 {
        AccountID = ApexPages.currentPage().getParameters().get('id');
                
        if(AccountID != null)

        {        mapAccountFields = Schema.SObjectType.Account.fields.getMap() ;

                objNewAccount = [ select id,OwnerId,AccountId,Status__c from Account where id = :AccountID ] ;

                objAccount = objNewAccount.Account(false,true,false,false);

             insert objaccount;

        return new PageReference('/'+objAccount.id);
    }
return null;
}

}

 
I would like to create a button that assigns existing cases. So far i have created a button that opens a new window and lists cases. The button errors as it expecting a ')' when all brackets are closed. I have blanked the URL's with [URL]
window.open ([URL])
<apex: column width="100px" headerValue= "ID" headerclass="TableTitle" value="{Case.Id}" />
<apex: Column headervalue="Name" headerclass="TableTitle" value="{case.subject}" />
 <apex: outputLink> value="[URL]" />
<a id="Existing Cases">[URL]/ </a></Apex: outputlink>
<apex:page controller="datalistcon">
 <apex:datalist> value="{Case.CaseNumber}" var="CaseNumber">
 <apex:outputText value="{CaseNumber}"/>
 </apex:dataList>
 </apex:page>
public class dataListCon {
List<Cases> Cases;
public List<Cases> GetCases(){
 if(cases == null) cases = [select CaseNumber, Subject from Cases Limit 10];
return Cases;
}
}
Hi experts,

I am trying to build the following approval processes:

1) Record is submitted for approval to a Related user 
2) Related user has 24 hours to approve/reject.
3) If the Related user does not approve in 24 hours the request goes to User A. 
(User A is the same user for all approvals. User A is not a direct manager or delegated manager of Related User)

How can this be accomplished?
  • February 11, 2016
  • Like
  • 0
The following relationship SOQL query was working fine in my Java app at API 34
 
select id, UserType, Contact.Id, Contact.AccountId, Contact.Name, Contact.Email, Account.Type, Account.Name from user where FederationIdentifier='1234'
Now is giving me an exception and compalining about This : -
No such column 'Type' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c'

The running user and profile is fine and have access to the field.
Also I ran the query as the user from Dev console and Wrokbench and is running fine.
Any ideas?
 
Team, 

I thought this trigger was working and I dont know how it is not now. When the secondary owner lookup field is populated on the opportunity I need it to create an opportunity with read write access. 

it is only giving the users Read Only access. 
Appreciate any help
trigger OTOpportunityTrigger on Opportunity (before update) {
    List<OpportunityTeamMember> listOpptyTeamMem = new List<OpportunityTeamMember>();
    Set<Id> OpptyIdSet  =  new Set<Id>();
    
    for(Opportunity oppty : trigger.New)
    {
        //Checking Oppty SecondaryOwner 
        if(oppty.Secondary_Owner__c != null)
        {
            OpportunityTeamMember OTM = new OpportunityTeamMember();
            OTM.OpportunityId = oppty.Id;
            OTM.TeamMemberRole = 'Secondary Owner'; 
            OTM.UserId = oppty.Secondary_Owner__c;
            listOpptyTeamMem.add(OTM);
        } 
    }
        
       
        if(listOpptyTeamMem.size() > 0)
        {
        insert listOpptyTeamMem;
                
        // get all of the team members' sharing recordsPost to Community
        List<OpportunityShare> shares = [select Id, OpportunityAccessLevel, 
          RowCause from OpportunityShare where OpportunityId IN : OpptyIdSet
          and RowCause = 'Team'];
 
        // set all team members access to read/write
        for (OpportunityShare share : shares) 
          share.OpportunityAccessLevel = 'Edit';
 
        update shares;
        }

}
Hi All,

I'm trying to replicate the standard "Send notification email to contact" checkbox, visible in the bottom of the Case edit page layout, in a custom Visualforce page.
If the user puts this flag, an email will be sent to the contact related to the case and this action will be historized as completed task, both in creation and editing.

I'm trying setting the "triggerAutoResponseEmail" parameter of the DMLOption class and passing this option in the update command.
This is my code:
public with sharing class MyController {

	private Case c;
	public Boolean sendEmail {get; set;}

	public MyController(ApexPages.StandardController ctrl) {
		c = (Case) ctrl.getRecord();
		sendEmail = false;
	}

	public PageReference save() {
		try {
			Database.DMLOptions dmo = new Database.DMLOptions();
			if(sendEmail) dmo.EmailHeader.triggerAutoResponseEmail = true;
			Database.update(c, dmo);
		} catch (Exception e) {}
	}

}

This code doesn't work because the parameter "triggerAutoResponseEmail" sends an email only after the case creation and not after editing.
How can I replicate the standard "Send notification email to contact" checkbox functionality via Apex?

Thank you in advance.
Edoardo
I have a custom app that has 3 levels of object in a master detail hierarchy. I had set the OWD so the top level was private. The records are created by members of TEAM A who should always have access to the records for all objects in the app. So I have given them modify all. There are then 2 levels of user below, TEAM MEMBERS can see their own records, i.e. those that related to them. In order to do this I have had to rely on TEAM A manually adding the TEAM MEMBER to the sharing on each record. I can't find a better way to do this at the moment as the app needs to be generic and I won't always know what the role hierarchy or groups are before installing.

Above TEAM MEMBERS are TEAM MANAGERS, they need to be able to view their own records like a TEAM MEMBER can, but also the records of THEIR TEAM. This is where I am struggling... TEAM MANAGERS need READ access to their teams records, but also Edit access to specific objects as they are using an approval cycle. However they can not have edit access to their own record, just their team.

I hope that makes sense. The key thing is that this is an app that will be installed in lots of orgs so I will not be aware of the security model of those beforehand.

In Summary:

TEAM A has CRUD to all records in app
TEAM MANGERS can read their own records, their teams records and be able to approve/update specific objects for their team
TEAM MEMBERS can read their own records only

Since I can't find a way to dynamically add users to a records I wonder how this might be done. The TEAM MANAGER is a new custom field added to the USER object so can be referenced.

Any ideas?
I am using a visualforce page email template in which Recipient is a Contact, relatedTo is an Event, it dynamically generates an *.ical Attachment. That works just fine by using

<apex:outputText value="{0,date,yyyyMMdd'T'HHmmss}"><apex:param value="{!relatedTo.StartDateTime}" /></apex:outputText>

What I am not able to achieve is to render a link to Google Calendar that needs the same formatting of StartDateTime/EndDateTime.

I've tried using outputtext as well, but SF prevents me of using that in < a href=''>, if I dont use < a href=''>, some clients wont render the Link as Link, i.e. it is not clickable which is not acceptable. For other reasons, I need to used < messaging:HtmlEmailBody > and cannot use PlainText.

So I tried dissecting my link into params and use Apex:Outputlink.

My approach is as follows:

<apex:OutputLink value="https://www.google.com/calendar/render">
Click me
<apex:param name="action" value="TEMPLATE"/>
<apex:param name="text" value="someValue"/>
<apex:param name="dates" value="{relatedTo.Startdatetime}Z/{!relatedTo.EndDateTime)}Z"/>
<apex:param name="details" value="someOtherValue"/>
<apex:param name="sf" value="true"/>
<apex:param name="output" value="xml"/>
</apex:OutputLink>



Is there any way to get that relatedTo.Startdatetime into the format yyyyMMdd followed by HHmmss in an apex param?

If not, can you think of any workarounds that work with the event object? (FYI: SF does not allow to use StartDateTime in a formula expression to create costums fields of the format needed)

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.