• The Admiral
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Life Fitness

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hi there,

I have on the object factuur__c a field named FS_Dagen_Open__c it is a formula counting day that the invoice is open. 
The trigger should update Aantal_Dagen_Openstaan on each record on the object.
It also should fire if field Betaald__c is False.

I am quite new to triggers and it seems that i have some issues here, any suggestions for improvements?
 
trigger nota Trigger on Factuur__c (before update) {
    //Create a list to hold the records that we are going to update
    List<Factuur__c> notaList = new List<Factuur__c>();
     Betaald = False
    
    //Go through the updated records in the database and update their custom fields 
    //according to the updated Aantal_dagen_openstaand__c in value of FS_Dagen_Open
    for(Factuur__c nota : Trigger.new)
    {
        if(nota. FS_Dagen_open__c = !=null)
        {
            nota.FS_Dagen_open__c =  Aantal_dagen_openstaand__c;
            
            //Put each updated record in the list we created
            notaList.add(nota);
        }
    }
    //Update the list in the database
    update notaList;

}

 
Hi there,

My flow comes to a decision and throws an error:
Flow cannot open the value because it is not been set or assigned.


I have decision element before to see if the value is checking it there, it checks if value is null, if the value is null it goes in another direction. Ultimately that decision should avoid the error I think but it doesn't.
This doesn't happen all the time just sometimes. 
Anyone has suggestions how to check?

The field name is GetAfdeling.Inf.AV__c , if its null then the flow should even check further..
thanks in advance!
Hi there,


Writing my second Test to check calculation I did with my trigger.
Quite new to writing apex tests so I took part of the test from first one and added here in but now I am lost.

20:34:26:101 EXCEPTION_THROWN [22]|System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Order__c, Investment__c]: [Order__c, Investment__c]
@isTest 
private class TestCurrentInvestmentValue {
    
    @IsTest
    static void CurrentOrEndvalueCalculated() {
        // Create Investment_rates__c
        Investment_rates__c ir = new Investment_rates__c(FundPrice__c=100, Participation_unit__c=50);
        Test.startTest();
        // Insert
        insert ir;
        Test.stopTest();
        // Select the record to get the data modified after the trigger
        ir = [SELECT CurrentorEndvalue__c, FundPrice__c, Participation_unit__c FROM Investment_rates__c WHERE Id =: ir.Id];
        // Check the values are as you espect
        System.assertEquals(ir.FundPrice__c*ir.Participation_unit__c, ir.CurrentorEndvalue__c);
    }
    Account account = new Account (Name='Test');
        insert account;
        Investment__c invest = new Investment__c (Account__c=account.Id);
        insert invest;
        Contract contract = new Contract (AccountId=account.Id,
                                         Status='Draft',
                                         StartDate=System.today() + 30,
                                         ContractTerm=30);
        insert contract;
        Order order = new Order (AccountId=account.Id,
                                 Status='Draft',
                                 ContractId=contract.Id,
                                 EffectiveDate=System.today() + 60
                                );
       	insert order;
        Investment_rates__c investrates = new Investment_rates__c (DailyFundRecord__c=dailyfund.Id,
                                                                  Investment__c=invest.id,
                                                                  Order__c=order.id,
                                                                  FundPrice__c=400,
                                                                  Status__c='Open',
                                                                  Contract__c=contract.id);
        insert investrates;


    @IsTest
    static void CurrentOrEndvalueNotCalculated() {
        Investment_rates__c ir = new Investment_rates__c();
        Test.startTest();
        insert ir;
        Test.stopTest();
        ir = [SELECT CurrentorEndvalue__c, FundPrice__c, Participation_unit__c FROM Investment_rates__c WHERE Id =: ir.Id];
        System.assertEquals(0, ir.CurrentorEndvalue__c);
    }

}

 
Might be a bit of a dumb question, or that nobody will answer that. It's mmkay.
But if U could guide me into right direction that would be great.

So I'm new in my company and they first task is to modify apex webform handler.
Well here it gets tricky. It needs to be modified only for 1 country. And it needs to have text added to the email that webform creates.
However it might be tricky for me, cause I really don't see where is this text coming from. Or where should it be added to.
Here is the code piece (If more info needed i can send u the whole code):

   // send email to User who filled out the form
    private void sendUserMail() {
        String userMailMessagePlain = Label.Email_Thankyou_Message_1 + '\n' + Label.Email_Thankyou_Message_2 + '\n\n' + setPlainTextMessage('\n');
        Messaging.SingleEmailMessage userMail = prepareEmail(new String[]{sfw.emailAddress}, Label.Sender_Display_Name, Label.Email_Subject_User, userMailMessagePlain);
        userMail.setHTMLBody(setHTMLMessage());
        if (sfw.imageFile.Name != NULL) {
            userMail.setFileAttachments(new Messaging.Emailfileattachment[] { getAttachmentForEmail() } );
        } 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { userMail });


I'm sure the language choice comes from this:

   }
        else if (sfw.language =='de') {
            serviceEmailAddress = 'kalalalalala@test.com';
        }

I'm quite sure it is based on:
http://www.topalovich.com/2011/12/create-a-custom-web-form-handler-with-force-com-sites/

This will be so "easy"
Hi there,

I checked on forum and couldn't find it really. But is there a way to make opportunity invisbile for 60 days? Only board members need to see the opportunity on the report....

Thanks
Hi there,

I have on the object factuur__c a field named FS_Dagen_Open__c it is a formula counting day that the invoice is open. 
The trigger should update Aantal_Dagen_Openstaan on each record on the object.
It also should fire if field Betaald__c is False.

I am quite new to triggers and it seems that i have some issues here, any suggestions for improvements?
 
trigger nota Trigger on Factuur__c (before update) {
    //Create a list to hold the records that we are going to update
    List<Factuur__c> notaList = new List<Factuur__c>();
     Betaald = False
    
    //Go through the updated records in the database and update their custom fields 
    //according to the updated Aantal_dagen_openstaand__c in value of FS_Dagen_Open
    for(Factuur__c nota : Trigger.new)
    {
        if(nota. FS_Dagen_open__c = !=null)
        {
            nota.FS_Dagen_open__c =  Aantal_dagen_openstaand__c;
            
            //Put each updated record in the list we created
            notaList.add(nota);
        }
    }
    //Update the list in the database
    update notaList;

}

 
Hi there,


Writing my second Test to check calculation I did with my trigger.
Quite new to writing apex tests so I took part of the test from first one and added here in but now I am lost.

20:34:26:101 EXCEPTION_THROWN [22]|System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Order__c, Investment__c]: [Order__c, Investment__c]
@isTest 
private class TestCurrentInvestmentValue {
    
    @IsTest
    static void CurrentOrEndvalueCalculated() {
        // Create Investment_rates__c
        Investment_rates__c ir = new Investment_rates__c(FundPrice__c=100, Participation_unit__c=50);
        Test.startTest();
        // Insert
        insert ir;
        Test.stopTest();
        // Select the record to get the data modified after the trigger
        ir = [SELECT CurrentorEndvalue__c, FundPrice__c, Participation_unit__c FROM Investment_rates__c WHERE Id =: ir.Id];
        // Check the values are as you espect
        System.assertEquals(ir.FundPrice__c*ir.Participation_unit__c, ir.CurrentorEndvalue__c);
    }
    Account account = new Account (Name='Test');
        insert account;
        Investment__c invest = new Investment__c (Account__c=account.Id);
        insert invest;
        Contract contract = new Contract (AccountId=account.Id,
                                         Status='Draft',
                                         StartDate=System.today() + 30,
                                         ContractTerm=30);
        insert contract;
        Order order = new Order (AccountId=account.Id,
                                 Status='Draft',
                                 ContractId=contract.Id,
                                 EffectiveDate=System.today() + 60
                                );
       	insert order;
        Investment_rates__c investrates = new Investment_rates__c (DailyFundRecord__c=dailyfund.Id,
                                                                  Investment__c=invest.id,
                                                                  Order__c=order.id,
                                                                  FundPrice__c=400,
                                                                  Status__c='Open',
                                                                  Contract__c=contract.id);
        insert investrates;


    @IsTest
    static void CurrentOrEndvalueNotCalculated() {
        Investment_rates__c ir = new Investment_rates__c();
        Test.startTest();
        insert ir;
        Test.stopTest();
        ir = [SELECT CurrentorEndvalue__c, FundPrice__c, Participation_unit__c FROM Investment_rates__c WHERE Id =: ir.Id];
        System.assertEquals(0, ir.CurrentorEndvalue__c);
    }

}

 
Trailhead Module 3:  Create a formula field that determines the number of days between today and the last activity date for a case's account.
Your support team has asked for improved visibility on account activity level at the time they’re helping with customer issues. Specifically, when they’re looking at a case, they’d like to see an at-a-glance view of the number of days since the case’s related account was last active. Create the formula using these requirements.The formula should be on the Case object.
The formula should be of return type Number.
The formula should be named 'Days Since Last Update' and have a resulting API Name of 'Days_Since_Last_Update__c'.
The formula should return the number of days between the account’s Last Activity Date and today.

I created the following:

I created a new custom formula field with return type number and called Days Since Last Update.
I created this formula: Account.LastActivityDate - TODAY()

I get this error message:

Challenge not yet complete... here's what's wrong: 
The 'Days_Since_Last_Update__c' formula field did not return the correct number of days between an Account’s Last Activity Date and today

Can you please assist what I did wrong?  I'm not sure if my formula is even correct with the challenge.  Please help!

Thank you.