• DanielBProbert
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hey,

 

I have 2 identical multi-pick lists that I would like to put a validation rule on.

 

MP 1 = Exams_Sat__c

 

Options = Exam 1, Exam 2, Exam 3, Exam 4

 

MP2 = Exams_Passed__c

 

Options = Exam 1, Exam 2, Exam 3, Exam 4

 

What i would like the rule to do is

 

IF Exam 1/2 & 4 were selected as exams Sat, when you come to set the passed exams if you select Exam 3 you get an error telling you that you have selected an exam that wasn't sat.

 

Any ideas or is this not possible?

 

Cheers

Dan

 

 

Hi All,

 

Another little trigger query(I am learning at least :))

 

So I have a requirement to update a master record based on a critera.

 

Master Object = Loan__c

Child Object = Loan_Repayments__c

 

The trigger needs to work like this,

 

IF Child Object is updated then after that update the trigger should look at Loan__c and then verify that number_of_repayments__c and payments_received__c are =, if they are equal then within Loan__c the field Loan_Status__c needs to be updated to show as Completed.

 

I found some code on here that I have tried to get in place but I actually think it's working the wrong way and would appreciate some pointers about the right way to deal with this.

 

I tried with a workflow but a workflow only works once the loan__c is edited/updated which won't be often.

 

trigger LoanCompletedUpdate on Loan_Repayments__c (after insert, after update) {
 
    
    list<Loan__c> lstLoan = new list<Loan__c>();  
    set<Id> Ids = new Set <Id>();           
    for (Loan_Repayments__c lrp: Trigger.new) {             
        Ids.add(lrp.Loan__c); 
    }
    
    Loan__c loan = [SELECT Id, Number_Of_Repayments__c, Payments_Received__c, Loan_Status__c FROM Loan__c WHERE Id IN :Ids];  
    
    if(trigger.isInsert || trigger.isUpdate)
    {   
        for(Loan_Repayments__c objC : trigger.new) 
        {
            IF (loan.Number_Of_Repayments__c!=loan.Payments_Received__c) 
            {
                
                loan.Loan_Status__c = 'Completed';
                lstLoan.add(loan);
            } 
        }
   }
   IF(lstLoan.size()>0)
         Update loan;
}

 

that codes doesn't seem to do anything when I make a change to the loan_repayments__c object.

 

cheers

dan

Hi All,

 

Another little trigger query(I am learning at least :))

 

So I have a requirement to update a master record based on a critera.

 

Master Object = Loan__c

Child Object = Loan_Repayments__c

 

The trigger needs to work like this,

 

IF Child Object is updated then after that update the trigger should look at Loan__c and then verify that number_of_repayments__c and payments_received__c are =, if they are equal then within Loan__c the field Loan_Status__c needs to be updated to show as Completed.

 

I found some code on here that I have tried to get in place but I actually think it's working the wrong way and would appreciate some pointers about the right way to deal with this.

 

I tried with a workflow but a workflow only works once the loan__c is edited/updated which won't be often.

 

trigger LoanCompletedUpdate on Loan_Repayments__c (after insert, after update) {
 
    
    list<Loan__c> lstLoan = new list<Loan__c>();  
    set<Id> Ids = new Set <Id>();           
    for (Loan_Repayments__c lrp: Trigger.new) {             
        Ids.add(lrp.Loan__c); 
    }
    
    Loan__c loan = [SELECT Id, Number_Of_Repayments__c, Payments_Received__c, Loan_Status__c FROM Loan__c WHERE Id IN :Ids];  
    
    if(trigger.isInsert || trigger.isUpdate)
    {   
        for(Loan_Repayments__c objC : trigger.new) 
        {
            IF (loan.Number_Of_Repayments__c!=loan.Payments_Received__c) 
            {
                
                loan.Loan_Status__c = 'Completed';
                lstLoan.add(loan);
            } 
        }
   }
   IF(lstLoan.size()>0)
         Update loan;
}

 

that codes doesn't seem to do anything when I make a change to the loan_repayments__c object.

 

cheers

dan

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!

Hi Community,

 

I'm new to apex and trigger but have created a simple trigger against a custom object Loan__c that after insert will create the repayment schedule in the custom related object Loan_Repayment__c

 

trigger generateloanrepayments on Loan__c (after insert) {
List <Loan_Repayments__c> prefToInsert = new List <Loan_Repayments__c> ();


for (Loan__c c : Trigger.new) {
Loan_Repayments__c p = new Loan_Repayments__c ();

p.Loan__c = c.Id;
p.Expected_Repayment_Date__c = c.Hidden_First_Payment_Date__c + 30;
p.CurrencyISOCode = c.CurrencyISOCode;

prefToInsert.add(p);

}
try {
insert prefToInsert;
} catch (system.Dmlexception e) {
system.debug (e);
}
}

 

 

This works well however what I now need to do is have this loop and create the entire repayment schedule based on the value that is stored in Loan__c.Number_of_Repayments__c.

 

So when Loan__c.Number_Of_Repayments__c = 5 there are 5 records creates.

 

Hope this makes sense and someone can help me.

 

Cheers

Dan