• Sameer Tyagi SFDC
  • NEWBIE
  • 239 Points
  • Member since 2015
  • Mirketa INC

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 66
    Replies
Hi,

I have a situation where a contact can own/work for multiple Accounts at the same time. 

I need to be able to have a single contact record but allow that contact to be principle of mulitple accounts (i.e. not just a role on supplementary accounts, but an actual contact). Is this possible, or do i have to use the Account Contact Roles junction, and just change the role types to be more meaningful? The problem with this is that the Contact Role doesn't appear in the 'Contact' related list; plus I can't edit the Contact Roles related list in the Account object - it shows the Account the Contact is actually linked to....

Any help would be great!

Thanks.
I have this trigger with the following test and i am only getting 31% coverage.  The concept of test still has me confused, any help would be greatly appreciated.
trigger AcceptanceSigned on Task (after insert, after update) {
    Set<Id> LogIds = new Set<Id>();
    Map<Id,Account> mapacctLogWithId = new Map<Id,Account>();
    Map<Id,Account> mapAccLogToUpdate = new Map<Id,Account>();
    
    for(Task t: trigger.new){
        if(t.WhatId != null && string.valueof(t.WhatId).startsWith('a01')){
            LogIds.add(t.WhatId);
        }
    }
    for(Account a:[SELECT Description, easy_workflow__c FROM Account WHERE ID IN:LogIds]){
        mapacctLogWithId.put(a.Id,a);
    }
    
    for(Task t: trigger.new){
        if(t.WhatId != null && string.valueof(t.WhatId).startsWith('a01') && t.Status == 'Completed' && mapacctLogWithId != null && mapacctLogWithId.get(t.WhatId) != null){
            Account accLog = new Account();
            if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) != null){
                accLog = mapAccLogToUpdate.get(t.WhatId);
            }
            else if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) == null){
                accLog = mapacctLogWithId.get(t.WhatId);
            }
            accLog.easy_workflow__c = accLog.easy_workflow__c + ';'+ t.subject;
            //accLog.easy_workflow__c = accLog.easy_workflow__c.replace(t.subject,'');
            if(t.Subject == 'Sign Acceptance Form'){
                accLog.Description = 'Acceptance Form Signed';    
            }
            mapAccLogToUpdate.put(accLog.Id,accLog);
        }
        
                if(t.WhatId != null && string.valueof(t.WhatId).startsWith('a01') && t.Status == 'Open' && mapacctLogWithId != null && mapacctLogWithId.get(t.WhatId) != null){
            Account accLog = new Account();
            if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) != null){
                accLog = mapAccLogToUpdate.get(t.WhatId);
            }
            else if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) == null){
                accLog = mapacctLogWithId.get(t.WhatId);
            }
            //accLog.easy_workflow__c = accLog.easy_workflow__c + ';'+ t.subject
                    if(accLog.easy_workflow__c != null && accLog.easy_workflow__c !=''){
            accLog.easy_workflow__c = accLog.easy_workflow__c.replace(t.subject,'');
                    }
            if(t.Subject == 'Sign Acceptance Form'){
                accLog.Description = 'Acceptance Form Signed';    
            }
            mapAccLogToUpdate.put(accLog.Id,accLog);
        }
    
    if(mapAccLogToUpdate != null && mapAccLogToUpdate.values() != null &&mapAccLogToUpdate.values().size() > 0){
        update mapAccLogToUpdate.values();
    }
    } }
@isTest(SeeAllData = true)
public class AcceptanceSignedTest {
         public static testMethod void testAcceptanceSigned(){
             test.startTest();
             Account testLog = new Account(name='Test', description = 'Test');
             insert testLog;
             
             Task testTask = new Task(Subject = 'Sign Acceptance Form', whatId = testLog.ID, Status = 'Completed');
             insert testTask;
             
             Account testLog2 = new Account(name='Test2', description = 'Test2');
             insert testLog2;
             
             Task testTask2 = new Task(Subject = 'Test', whatId = testLog2.ID, Status = 'Completed');
             insert testTask2;
             
             Account testLoga = new Account(name='Test', description = 'Test');
             insert testLoga;
             
             Task testTaska = new Task(Subject = 'Sign Acceptance Form', whatId = testLog.ID, Status = 'Open');
             insert testTaska;
             
             Account testLog2a = new Account(name='Test2', description = 'Test2');
             insert testLog2a;
             
             Task testTask2a = new Task(Subject = 'Test', whatId = testLog2.ID, Status = 'Open');
             insert testTask2a;
             test.stopTest();
        }
}


 
I have a Visualforce Edit Page and I want some of the fields to display readonlyI have tried this
<apex:outputfield value="{!Item.Item_Code__c}"/> but it only displays the label
select  Name from Opportunity where CloseDate > 2014-11-08T00:00:00Z

When I used this soql to query in the developer console,I got the following  error message:
value of filter criterion for field 'CloseDate' must be of type of date and should not be enclosed in quotes 

I am sure the CloseDate is a Date type. how to correct the query soql to make it work.
Hi,
We have implemented the following,
1: The OWD on contact is set to private
2: A particular profile do not have modify All Contacts permission
3: When any non admin user create a contact its ownership will change to Admin (i.e if a user ABC creates a contact then the workflow fires and change the owner of that contact to Admin)

If a contact is created without account then the contact is not editable by the user who has created the contact.Is there any way to enable edit feature on that , we tried with apex sharing, still the contact is not editable . Please help if anyone knows the solution

Thanks in advance.
 

Below lines taken from Salesforce Apex Code Developer's guide:
'if you update or delete a record in its before trigger, or delete a record in its after trigger, you will receive a runtime
error.This includes both direct and indirect operations. For example, if you update account A, and the before update trigger
of account A inserts contact B, and the after insert trigger of contact B queries for account A and updates it using the DML
update statement or database method, then you are indirectly updating account A in its before trigger, and you will receive
a runtime error'


But I can update the Contact description in the before update trigger. Below is the code:

trigger triggerAllContextVariableCheck on Contact (before update, after update, before insert, after insert) {
    if(Trigger.isBefore){
     if(Trigger.isUpdate){
         for(Contact c: trigger.new){
             c.Description='Before Update'; 
         }}}
}

What I am missing? Above code is updating the Contact record in it's before trigger but the statement in the book says something else.

Please explain.

Hi,

I have a situation where a contact can own/work for multiple Accounts at the same time. 

I need to be able to have a single contact record but allow that contact to be principle of mulitple accounts (i.e. not just a role on supplementary accounts, but an actual contact). Is this possible, or do i have to use the Account Contact Roles junction, and just change the role types to be more meaningful? The problem with this is that the Contact Role doesn't appear in the 'Contact' related list; plus I can't edit the Contact Roles related list in the Account object - it shows the Account the Contact is actually linked to....

Any help would be great!

Thanks.
hi all...
         actually when we delete an account, i need to create a new contact with the details of deleted account. how can we do this using apex triggers
  • April 09, 2015
  • Like
  • 0
Hi all,
I have a VF page with a save button using only the standard controller. When the save button is clicked, the entire page was being loaded in the VF section. 
So, I tried using the commandlink with the target_parent like -
<apex:commandLink value="Save" action="{!save}" target="_parent" styleClass="btn">
This worked fine in Chrome and Firefox but didn't work in IE despite checking all settings on IE. It opened a new window in IE with just the VF page.

So, I modified this to a command button like -
<apex:commandButton value="Save" action="{!save}" onclick="window.top.location='/{!<object>.id}'; return true"/>
But this doesn't save the record at all times. The behavior is erratic. At times, it does save the record and at times it doesn't. This behavior is noted on all browsers.

Please assist.

 
Hello all,
I am new to SFDC and started development in Apex and Visualforce Page with tutorials and online samples. 
So, here what I have tried and got stuck at the point. 

What I am trying to achieve:
1. In VF page, I want to show Custom field's values of Picklist data type in tabular format (In one of the coulmn) and it should be as Outputfield but not as a Inputfield.
2. In VF page, I want to access Custom field's values of Picklist data type of my Custom Object in tabular format (In one of the coulmn) and it should be as Outputfield but not as a Inputfield.

What I have tried to achieve 1st use case:

1. In Contact custom fields, I have created new Custom Picklist "interested_technologies__c" and there was already custom field "Level__c"  of picklist data type. 
2. I have created VF ("CustomerSearch") and Apex class ("ContactSearchController") as follows:

VF Page - CustomerSearch
<apex:page controller="ContactSearchController" sidebar="false">

  <apex:form >
<apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!contacts}" var="contact">

      <apex:column headervalue="Technologies">
               <apex:outputField value="{!contact.interested_technologies__c}" rendered="true">    </apex:outputField>
            </apex:column>
            
      <apex:column headervalue="Levels">
                <apex:outputField value="{!contact.Level__c}" rendered="true">
                 </apex:outputField>
            </apex:column>

      </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex class - ContactSearchController 
public with sharing class ContactSearchController {

  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of contacts to display
  public List<Contact> contacts {get;set;}

 // init the controller and display some sample data when the page loads
  public ContactSearchController() {
    soql = 'select interested_technologies__c, Level__c from contact ';
  }

  // use apex describe to build the picklist values
  public List<String> technologies {
    get {
      if (technologies == null) {

        technologies = new List<String>();
        Schema.DescribeFieldResult field = Contact.interested_technologies__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          technologies.add(f.getLabel());

      }
      return technologies;          
    }
    set;
  }
  
 // use apex describe to build the picklist values
  public List<String> levels{
    get {
      if (levels == null) {

        levels = new List<String>();
        Schema.DescribeFieldResult field = Contact.Level__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          levels.add(f.getLabel());

      }
      return levels;          
    }
    set;
  }

}

Problem and queries:

1. Here, I can see  Picklist values on VF Page for "Levels" and not for "Technologies". 
2. This is bit wierd behaviour as everything is the same except "Level__c" custom field was already created and "interested_technologies__c" custom field which I created.
3. Am I missing or doing some mistakes here? Or Is there any accessibility issues?  
4. FYI, I can see both custom fields picklist values using inputfield. 
5. I am free user on Salesfroce and profile has been set as a System Administrator in my app. 

Any recommendations would be highly appreciated. 

Thanks and regards,
Onkar. 

 



 
I'm New to Apex coding,  I have requirement where I need to insert 500000 records into an object using Batch Apex.
It can be done via Data loader, but I wanted to try it using Batch Apex. guide me please.
Thanks in advance.
Hi
We have a button on an opportunity that when we click it takes the user to a VF page however i am looking to revert page to teh standard page layout for thsi object can someone explain how and where i can do this please.

Thanks
Fiona
PS - Need it in simple terms no really that technical.
 am retreiving  opportunity records  under a contact (Contact Related list opportunities)  and displaying in a page table......i  am retreving all data  and every thing is good.  But i want add a filter condition where  sample Hype = true. then  all opportunity records under contact where sample hypo field is true should need to retrive.  But  after applying  condition i am getting  Referring a Null object exception for Olist.add(Op)  in below code.  I rendered the Olist in VF page pageblock table. I am not getting error in the code/VF.. after  rendered this to a button. After click buttoon it need to pull records and display here i am getting error.


public with sharing class OppRelatedData {

public Id sid{get;set;}
public string sname{get;set;}    


public list<Opportunity> OppRecords {get; set;}
public list<Opportunity> Olist = new list<Opportunity>();
 
contact cn = new contact();
string contactId = ApexPages.currentPage().getParameters().get('rec');
public OppRelatedData(ApexPages.StandardController controller) {

try{
if(ApexPages.currentPage().getParameters().get('rec')!=null){
 OppRecords = [select id,name,Amount,Sample_Hypo__c,Client_Meeting_Date__c,CloseDate,CreatedDate,Last_Activity_Date__c,LastModifiedDate,StageName,Product_Interest__c,Product_Riders__c from Opportunity WHERE Contact_Name__r.id =:ContactId  AND (not StageName LIKE '%close%') ORDER BY CloseDate ASC ];
System.debug('Opprecords'+OppRecords );
 for(Opportunity op:OppRecords){
 if(op.Sample_Hypo__c == true){
 
 Olist.add(op);
 System.debug('Olist'+Olist);
 
 }
 }
 update Olist;

}
else
System.Debug('There is no contact associated with Opportunity');
}

catch(DmlException e){
System.Debug(e.GetMessage());
}
}
}
Hi,

I am getting the error as'SendEmail failed. First exception on row 0; first error: UNVERIFIED_SENDER_ADDRESS, Organization-Wide Email Address has not be verified for use' from the test class. 

I have given the verified Organization-Wide Email Addresses to fromaddress field. Still i am facing the issue. Please let me know how can i solve the issue,

Thanks,
lakshmi.
I have this trigger with the following test and i am only getting 31% coverage.  The concept of test still has me confused, any help would be greatly appreciated.
trigger AcceptanceSigned on Task (after insert, after update) {
    Set<Id> LogIds = new Set<Id>();
    Map<Id,Account> mapacctLogWithId = new Map<Id,Account>();
    Map<Id,Account> mapAccLogToUpdate = new Map<Id,Account>();
    
    for(Task t: trigger.new){
        if(t.WhatId != null && string.valueof(t.WhatId).startsWith('a01')){
            LogIds.add(t.WhatId);
        }
    }
    for(Account a:[SELECT Description, easy_workflow__c FROM Account WHERE ID IN:LogIds]){
        mapacctLogWithId.put(a.Id,a);
    }
    
    for(Task t: trigger.new){
        if(t.WhatId != null && string.valueof(t.WhatId).startsWith('a01') && t.Status == 'Completed' && mapacctLogWithId != null && mapacctLogWithId.get(t.WhatId) != null){
            Account accLog = new Account();
            if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) != null){
                accLog = mapAccLogToUpdate.get(t.WhatId);
            }
            else if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) == null){
                accLog = mapacctLogWithId.get(t.WhatId);
            }
            accLog.easy_workflow__c = accLog.easy_workflow__c + ';'+ t.subject;
            //accLog.easy_workflow__c = accLog.easy_workflow__c.replace(t.subject,'');
            if(t.Subject == 'Sign Acceptance Form'){
                accLog.Description = 'Acceptance Form Signed';    
            }
            mapAccLogToUpdate.put(accLog.Id,accLog);
        }
        
                if(t.WhatId != null && string.valueof(t.WhatId).startsWith('a01') && t.Status == 'Open' && mapacctLogWithId != null && mapacctLogWithId.get(t.WhatId) != null){
            Account accLog = new Account();
            if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) != null){
                accLog = mapAccLogToUpdate.get(t.WhatId);
            }
            else if(mapAccLogToUpdate != null && mapAccLogToUpdate.get(t.WhatId) == null){
                accLog = mapacctLogWithId.get(t.WhatId);
            }
            //accLog.easy_workflow__c = accLog.easy_workflow__c + ';'+ t.subject
                    if(accLog.easy_workflow__c != null && accLog.easy_workflow__c !=''){
            accLog.easy_workflow__c = accLog.easy_workflow__c.replace(t.subject,'');
                    }
            if(t.Subject == 'Sign Acceptance Form'){
                accLog.Description = 'Acceptance Form Signed';    
            }
            mapAccLogToUpdate.put(accLog.Id,accLog);
        }
    
    if(mapAccLogToUpdate != null && mapAccLogToUpdate.values() != null &&mapAccLogToUpdate.values().size() > 0){
        update mapAccLogToUpdate.values();
    }
    } }
@isTest(SeeAllData = true)
public class AcceptanceSignedTest {
         public static testMethod void testAcceptanceSigned(){
             test.startTest();
             Account testLog = new Account(name='Test', description = 'Test');
             insert testLog;
             
             Task testTask = new Task(Subject = 'Sign Acceptance Form', whatId = testLog.ID, Status = 'Completed');
             insert testTask;
             
             Account testLog2 = new Account(name='Test2', description = 'Test2');
             insert testLog2;
             
             Task testTask2 = new Task(Subject = 'Test', whatId = testLog2.ID, Status = 'Completed');
             insert testTask2;
             
             Account testLoga = new Account(name='Test', description = 'Test');
             insert testLoga;
             
             Task testTaska = new Task(Subject = 'Sign Acceptance Form', whatId = testLog.ID, Status = 'Open');
             insert testTaska;
             
             Account testLog2a = new Account(name='Test2', description = 'Test2');
             insert testLog2a;
             
             Task testTask2a = new Task(Subject = 'Test', whatId = testLog2.ID, Status = 'Open');
             insert testTask2a;
             test.stopTest();
        }
}


 
Hi all,

In our customer portal we have users created through "Enable Customer Users" option in contact. While saving user unfortunately I am getting an exception from our trigger that contact Id is null. I am facing this issue while creating user through contact. I guess something went wrong in latest release?

Any suggestions please?
  • January 14, 2015
  • Like
  • 0
Hi all,
I have a VF page with a save button using only the standard controller. When the save button is clicked, the entire page was being loaded in the VF section. 
So, I tried using the commandlink with the target_parent like -
<apex:commandLink value="Save" action="{!save}" target="_parent" styleClass="btn">
This worked fine in Chrome and Firefox but didn't work in IE despite checking all settings on IE. It opened a new window in IE with just the VF page.

So, I modified this to a command button like -
<apex:commandButton value="Save" action="{!save}" onclick="window.top.location='/{!<object>.id}'; return true"/>
But this doesn't save the record at all times. The behavior is erratic. At times, it does save the record and at times it doesn't. This behavior is noted on all browsers.

Please assist.

 
Hey Friends,
     Is it Possible to override 'New' button of standard object 'Product' with visualforce page.?
     Plz tell me itz very urgent.