• Leonardo Girgenti 5
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 5
    Replies
Dear all,
I have 2 custom fields on the Contract object. 
Contract Status and Contract Validity

I need to ensure that everytime the Contract record is edited and saved, the Contract Status and Contract Validity fields are updated in the corresponding custom fields on the Account Object. 
I need trigger and test class!!
Thanks 
Hi there,
We at UNICEF require a little help with the creation of a Trigger and related TestClass for the following scenario:

We have a custom object called Due Diligence (Due_Diligence__c).
This is an object that has a MasterDetail relation to Account.
 
Due Diligence records are managed by researchers and the process ends with a DD Outcome assigned to the Due Diligence Record (PickList field called: DD_Phase_1_Outcome__c) at the DD record level.
The record is then put through a standard Approval Process.
 
We would like that at the Approval, when DD record is approved the approval process updates a field on the Due Diligence record called DD Record Status (Approval_status__c) with a status of “Phase 1 Review Completed”, the DD record then updates the Account in the relevant field in the Account record (DD_Outcome_Phase_1__c) with the outcome coming from the DD Records.
 
We would also want to pass the Approval Date also from the DD Record to the Account record.

Currently we are handling that via a series of Workflow but we only have the ability to update the Account record after 1 hour (we are using Time Based Field Updates) 
Thanks,
L
Hello all,
I have a custom object called Meetings.
I have a join called Meeting Participants between Meeting and Contacts called Contacts_in_bilaterals__c.

I would like a trigger to fire everytime there is a new Meeting Participants added in the join to go and populate the concatenated name and title of the Contact (I have already that field on the Contact) in a freetext field on the Meetings record.
Would like to have is to if new meeting participants are added, the new ones come under the one already there, pehaps separated by a carriage return or else.
Thanks
Can anyone help me to write the Test Class for this Trigger?
I am not skilled to write it up so really need help. Thanks


trigger MeetingParticipantTrigger on Meeting_Participants__c(before insert){
    Set<Id> contactIds = new Set<Id>();
    for(Meeting_Participants__c mp : Trigger.new){

        contactIds.add(mp.Contact__c);

    }
    Map<Id,Contact> contacts = new Map<Id,Contact>([Select AccountId From Contact Where Id in :contactIds]);

    for(Meeting_Participants__c mp : Trigger.new){

        Contact c = contacts.get(mp.Contact__c);

        mp.Account2__c = c.AccountId;

    }
}
hi there, 
could anyone help me with a test class for  this trigger?
thanks in advance

trigger MeetingParticipantTrigger on Meeting_Participants__c(before insert){
Set<Id> contactIds = new Set<Id>();
for(Meeting_Participants__c mp : Trigger.new){
contactIds.add(mp.Contact__c);
}
Map<Id,Contact> contacts = new Map<Id,Contact>([Select AccountId From Contact Where Id in :contactIds]);
for(Meeting_Participants__c mp : Trigger.new){
Contact c = contacts.get(mp.Contact__c);
mp.Account2__c = c.AccountId;
}
}

 
Dear all,
thank you in advance for you help.
i have a new custom object called Meetings.
then I have a Join object called Meeting Participants, that links Contacts to Meetings.
I would like to ensure that the meeting also show in the Account of the Contacts selected as Meeting Participants.
I need a trigger that automatically puts the selected contact's account in the Account field that I have in the Join Object.
Workflow dont seem to help here as the target field is a lookup.
I could look into process builder but I think a simple trigger should work.
i am purpously not using activities as we need several rich text fields on the Meeting Record and need to use SDoc or Conga to generate and print documents of the meeting.
 
Would anyone help me with the trigger creation??
thanks,
Leonardo
i have this trigger, can anyone provide me with the relevant unit test?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
trigger CreatePhotoDoc on Contact (before update) {

id fid=[select id from folder where name = 'Shared Documents'].id;
for (contact c : trigger.new){
string purl = c.photouploader__Image_URL__c;
if (Trigger.oldMap.get(c.Id).photouploader__Image_URL__c != purl  && purl !=null){
    string attid = purl.substring(purl.indexof('file=')+5,purl.length());
    attachment a = [select body,name,contenttype from attachment where id = :attid];
    Document doc;
    for (document d: [select id from document where name = :c.id])
        doc=d;
    if (doc==null)
        doc = new document();
    doc.Name = c.id;
    doc.Description = c.id + '/' + a.name;
    doc.FolderId = fid;//'00lj0000000qTMG';
    doc.Body = a.body;
    doc.type=a.name.substring(a.name.indexof('.')+1,a.name.length());
    doc.ispublic=true;
    upsert doc;
    string instance=null;
    string [] p = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.');
    if (p.size() == 3) Instance = p[0];
        else if (p.size() == 5) Instance = p[1];
    c.sdocs_image_url__c='<img src="https://c.' +instance +'.content.force.com/servlet/servlet.ImageServer?id=' + doc.id +'&oid='+UserInfo.getOrganizationId()+'" />';
    }
}
}
Can anyone help me to write the Test Class for this Trigger?
I am not skilled to write it up so really need help. Thanks


trigger MeetingParticipantTrigger on Meeting_Participants__c(before insert){
    Set<Id> contactIds = new Set<Id>();
    for(Meeting_Participants__c mp : Trigger.new){

        contactIds.add(mp.Contact__c);

    }
    Map<Id,Contact> contacts = new Map<Id,Contact>([Select AccountId From Contact Where Id in :contactIds]);

    for(Meeting_Participants__c mp : Trigger.new){

        Contact c = contacts.get(mp.Contact__c);

        mp.Account2__c = c.AccountId;

    }
}
hi there, 
could anyone help me with a test class for  this trigger?
thanks in advance

trigger MeetingParticipantTrigger on Meeting_Participants__c(before insert){
Set<Id> contactIds = new Set<Id>();
for(Meeting_Participants__c mp : Trigger.new){
contactIds.add(mp.Contact__c);
}
Map<Id,Contact> contacts = new Map<Id,Contact>([Select AccountId From Contact Where Id in :contactIds]);
for(Meeting_Participants__c mp : Trigger.new){
Contact c = contacts.get(mp.Contact__c);
mp.Account2__c = c.AccountId;
}
}

 
Dear all,
thank you in advance for you help.
i have a new custom object called Meetings.
then I have a Join object called Meeting Participants, that links Contacts to Meetings.
I would like to ensure that the meeting also show in the Account of the Contacts selected as Meeting Participants.
I need a trigger that automatically puts the selected contact's account in the Account field that I have in the Join Object.
Workflow dont seem to help here as the target field is a lookup.
I could look into process builder but I think a simple trigger should work.
i am purpously not using activities as we need several rich text fields on the Meeting Record and need to use SDoc or Conga to generate and print documents of the meeting.
 
Would anyone help me with the trigger creation??
thanks,
Leonardo
i have this trigger, can anyone provide me with the relevant unit test?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
trigger CreatePhotoDoc on Contact (before update) {

id fid=[select id from folder where name = 'Shared Documents'].id;
for (contact c : trigger.new){
string purl = c.photouploader__Image_URL__c;
if (Trigger.oldMap.get(c.Id).photouploader__Image_URL__c != purl  && purl !=null){
    string attid = purl.substring(purl.indexof('file=')+5,purl.length());
    attachment a = [select body,name,contenttype from attachment where id = :attid];
    Document doc;
    for (document d: [select id from document where name = :c.id])
        doc=d;
    if (doc==null)
        doc = new document();
    doc.Name = c.id;
    doc.Description = c.id + '/' + a.name;
    doc.FolderId = fid;//'00lj0000000qTMG';
    doc.Body = a.body;
    doc.type=a.name.substring(a.name.indexof('.')+1,a.name.length());
    doc.ispublic=true;
    upsert doc;
    string instance=null;
    string [] p = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.');
    if (p.size() == 3) Instance = p[0];
        else if (p.size() == 5) Instance = p[1];
    c.sdocs_image_url__c='<img src="https://c.' +instance +'.content.force.com/servlet/servlet.ImageServer?id=' + doc.id +'&oid='+UserInfo.getOrganizationId()+'" />';
    }
}
}