• Gaspar
  • NEWBIE
  • 15 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 13
    Replies
Hello, I'm wondering if it's possible to do this without code. 

Objone__c has a lookup relationship with Objtwo__c 
Objone__c has an input picklist field called Picklist__c
Objtwo__c has an input picklist field called Picklist_existing__c

When creating a record on Objone__c, where "RecordType" = "X", I need Objone__c.Picklist__c to be populated from a picklist field of the related (selected) Objtwo__c record (Objtwo__c.Picklist_existing__c) after insert and after update. 

Is this possible without code? 
  • March 02, 2015
  • Like
  • 0

Hello, I've written the following trigger to create a Payment__c record when a Deal_Participation__c record is created where RecordType = 'Seller Participation.' The trigger is behaving correctly for after insert BUT when an existing Deal_Participation__c record is updated, it creates another new Payment__c record instead of updating the Payment__c record. I think I need to rewrite the payments.add(new.Payments__c)... bit but I'm not sure how to do it. Any help is greatly appreciated!

 

 

trigger createSellerPayments on Deal_Participation__c (after Insert, after Update) {

 

List<Payments__c> payments = new List<Payments__c>();
ID rtId = [SELECT Id FROM RecordType WHERE Name = 'Seller Participation'].Id;
List<RecordType> PmntRecordType = [Select Id from recordType where Name = 'Outgoing Seller Payment' AND SobjectType= 'Payments__c'];

 

for (Deal_Participation__c newPayment: Trigger.New) {

if (newPayment.Deal_Relationship__c != null) {

if(newpayment.RecordTypeId == rtId){

payments.add(new Payments__c(

RecordTypeId = PmntRecordType[0].id,
Deal_Participation_Relationship__c = newPayment.Id));
}
}
}

insert payments;

}

  • December 02, 2013
  • Like
  • 0

Hello, I'm trying to finalize a trigger to update. I am receiving an error on foreign key invalid relationships.

 

- Implementation_Site__c is child to Grant__c

- Country__c field is on Implementation_Site__c

- Countries__c is on Grant__c  - this is the field that needs to be populated with infinite number of Country__c values coming from child records. 

 

Current code:

 

//This Trigger will fire after insert, update, delete and undelete
trigger trgConCatCountries on Implementation_Site__c (after insert, after update, after delete, after undelete) {

//If the event is insert or undelete, this list takes New Values or else it takes old values
List<Implementation_Site__c> ProjStrategyList = (Trigger.isInsert|| Trigger.isUnDelete) ? Trigger.new : Trigger.old;

//to store Project Ids
List<Id> ProjectIds = new List<Id>();

//Loop through the Records to store the project Id values from the Implementation Site
for (Implementation_Site__c proj_Strat : ProjStrategyList) {
ProjectIds.add(proj_Strat.Grant__c);
}

//Sub-query to get the projects and all its Child Records where Id is equal to the Ids stored in ProjectIds
//Implementation_Sites__r is the Child Relationship name appended by '__r' as it is a custom object

List<Grant__c> ProjectList = [
select
id,
(select id,Name, Grant__r.Name, Country__c, District_State__c from Implementation_Sites__r),
Grant__c
from
Grant__c
where
id in :ProjectIds];
//Loop through the List and store the Child Records as a String of values in Long Text Area Field i.e Countries__c

for (Grant__c proj : ProjectList) {

if(proj.Implementation_Sites__r.size() > 0)
{
proj.Countries__c = string.valueOf(proj.Implementation_Sites__r[0].Country__c);

for(integer i=1;i < proj.Implementation_Sites__r.size();i++)
{
proj.Countries__c = proj.Countries__c + '; ' + string.valueOf(proj.Implementation_Sites__r[i].Country__c);
}
}
else
proj.Countries__c = null;

}

//update the List
update ProjectList;


}

 

 

Help! Thanks!

 

  • August 09, 2013
  • Like
  • 1
Use Case: For an internal system that crowd sources innovative ideas (Innovations) and recommendations from across the globe in order to become a more effective and connected organization.
 
Specs: The submission progression goes from Idea (Stage1) to Concept (Stage 2) to Prototype (Stage 3) to Execution (Stage 4). Each stage has different fields, due dates and individual forms. The formula lies in Due Dates. Currently, we have it set up so that Stage 2 is 20 days after Stage 1 Submission Date, and so on. One requested data point for Stage 2, 3 and 4 is "Number of Days estimated until Completion of Innovation." This values needs to be used to allow the submitting team to set the due date for the next form/next stage. I want this individualized approach to each innovation instead of having it based on a cross cutting 20 days-from-submission-date formula. 
 
Formula should: Add the number value in the "Number of Days estimated until Completion of Innovation" to Stage 1/2/3 Submission Date and populate Stage 2/3/4 Due Dates given that calculation.
 
Example: If my submission date for Stage 2 is May 1, 2013, and my "Number of Days" field is 15 - upon submission the formula should calculate that the Stage 3 Due Date is May 16, 2013. 
 
Any thoughts/solutions are greatly appreciated!

Hello, I need help writing a simple trigger that runs the Object Converter App without having to use the detail page button. The event would be when the Lead is converted and creates the Account, the trigger would continue the process (after insert) and convert the Account to custom object Organisation_c based on the AccntToOrg field map.  

 

The "Convert to Organisation" custom detail page button currently executes the following URL: 

 

/apex/objcnvtr__objcnvtr_smartengine?id={!Account.Id}&mid=AccntToOrg

 

The trigger code suggested by the Object Converter App is: 

 

global static sObject OBJCNVTR__SmartEngine.Convert(sObject oSObject, string s

trMID){}

 

So: global static sObject OBJCNVTR__SmartEngine.Convert(sObject Account, string AccntToOrg){}

 

When do I define the Target object? What else do I need to run this process?

 

Also, can this be achieved without a trigger?

 

Thanks in advance for your help!

 

 

 

 

  • February 12, 2013
  • Like
  • 0

Hello, I'm trying to finalize a trigger to update. I am receiving an error on foreign key invalid relationships.

 

- Implementation_Site__c is child to Grant__c

- Country__c field is on Implementation_Site__c

- Countries__c is on Grant__c  - this is the field that needs to be populated with infinite number of Country__c values coming from child records. 

 

Current code:

 

//This Trigger will fire after insert, update, delete and undelete
trigger trgConCatCountries on Implementation_Site__c (after insert, after update, after delete, after undelete) {

//If the event is insert or undelete, this list takes New Values or else it takes old values
List<Implementation_Site__c> ProjStrategyList = (Trigger.isInsert|| Trigger.isUnDelete) ? Trigger.new : Trigger.old;

//to store Project Ids
List<Id> ProjectIds = new List<Id>();

//Loop through the Records to store the project Id values from the Implementation Site
for (Implementation_Site__c proj_Strat : ProjStrategyList) {
ProjectIds.add(proj_Strat.Grant__c);
}

//Sub-query to get the projects and all its Child Records where Id is equal to the Ids stored in ProjectIds
//Implementation_Sites__r is the Child Relationship name appended by '__r' as it is a custom object

List<Grant__c> ProjectList = [
select
id,
(select id,Name, Grant__r.Name, Country__c, District_State__c from Implementation_Sites__r),
Grant__c
from
Grant__c
where
id in :ProjectIds];
//Loop through the List and store the Child Records as a String of values in Long Text Area Field i.e Countries__c

for (Grant__c proj : ProjectList) {

if(proj.Implementation_Sites__r.size() > 0)
{
proj.Countries__c = string.valueOf(proj.Implementation_Sites__r[0].Country__c);

for(integer i=1;i < proj.Implementation_Sites__r.size();i++)
{
proj.Countries__c = proj.Countries__c + '; ' + string.valueOf(proj.Implementation_Sites__r[i].Country__c);
}
}
else
proj.Countries__c = null;

}

//update the List
update ProjectList;


}

 

 

Help! Thanks!

 

  • August 09, 2013
  • Like
  • 1
Hello, I'm wondering if it's possible to do this without code. 

Objone__c has a lookup relationship with Objtwo__c 
Objone__c has an input picklist field called Picklist__c
Objtwo__c has an input picklist field called Picklist_existing__c

When creating a record on Objone__c, where "RecordType" = "X", I need Objone__c.Picklist__c to be populated from a picklist field of the related (selected) Objtwo__c record (Objtwo__c.Picklist_existing__c) after insert and after update. 

Is this possible without code? 
  • March 02, 2015
  • Like
  • 0

Hello, I'm trying to finalize a trigger to update. I am receiving an error on foreign key invalid relationships.

 

- Implementation_Site__c is child to Grant__c

- Country__c field is on Implementation_Site__c

- Countries__c is on Grant__c  - this is the field that needs to be populated with infinite number of Country__c values coming from child records. 

 

Current code:

 

//This Trigger will fire after insert, update, delete and undelete
trigger trgConCatCountries on Implementation_Site__c (after insert, after update, after delete, after undelete) {

//If the event is insert or undelete, this list takes New Values or else it takes old values
List<Implementation_Site__c> ProjStrategyList = (Trigger.isInsert|| Trigger.isUnDelete) ? Trigger.new : Trigger.old;

//to store Project Ids
List<Id> ProjectIds = new List<Id>();

//Loop through the Records to store the project Id values from the Implementation Site
for (Implementation_Site__c proj_Strat : ProjStrategyList) {
ProjectIds.add(proj_Strat.Grant__c);
}

//Sub-query to get the projects and all its Child Records where Id is equal to the Ids stored in ProjectIds
//Implementation_Sites__r is the Child Relationship name appended by '__r' as it is a custom object

List<Grant__c> ProjectList = [
select
id,
(select id,Name, Grant__r.Name, Country__c, District_State__c from Implementation_Sites__r),
Grant__c
from
Grant__c
where
id in :ProjectIds];
//Loop through the List and store the Child Records as a String of values in Long Text Area Field i.e Countries__c

for (Grant__c proj : ProjectList) {

if(proj.Implementation_Sites__r.size() > 0)
{
proj.Countries__c = string.valueOf(proj.Implementation_Sites__r[0].Country__c);

for(integer i=1;i < proj.Implementation_Sites__r.size();i++)
{
proj.Countries__c = proj.Countries__c + '; ' + string.valueOf(proj.Implementation_Sites__r[i].Country__c);
}
}
else
proj.Countries__c = null;

}

//update the List
update ProjectList;


}

 

 

Help! Thanks!

 

  • August 09, 2013
  • Like
  • 1

Hello, I need help writing a simple trigger that runs the Object Converter App without having to use the detail page button. The event would be when the Lead is converted and creates the Account, the trigger would continue the process (after insert) and convert the Account to custom object Organisation_c based on the AccntToOrg field map.  

 

The "Convert to Organisation" custom detail page button currently executes the following URL: 

 

/apex/objcnvtr__objcnvtr_smartengine?id={!Account.Id}&mid=AccntToOrg

 

The trigger code suggested by the Object Converter App is: 

 

global static sObject OBJCNVTR__SmartEngine.Convert(sObject oSObject, string s

trMID){}

 

So: global static sObject OBJCNVTR__SmartEngine.Convert(sObject Account, string AccntToOrg){}

 

When do I define the Target object? What else do I need to run this process?

 

Also, can this be achieved without a trigger?

 

Thanks in advance for your help!

 

 

 

 

  • February 12, 2013
  • Like
  • 0

Hi,

 

As part of the approval workflow in salesforce, when a request is either approver or rejected, an email goes back to the submitter notifying that his/her request has been approved and/or rejected. Is there a way to include Approver's comments in that email so that Submitter knows the reason why it was approved/rejected? It seems simple enought to just pull Approver's Comments field on the email however we've been told that it isn't easy to accomplish. If anyone has done this before, I would appreciate if you could share your knowledge on this matter. Thanks.