• McAdmin
  • NEWBIE
  • 0 Points
  • Member since 2009

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

I am looking for resources other than the wiki, for the Time Off Manager Application (specifically for the time off balance). I am finding that resources for this application are limited. If any one has any experience using this application or knows where I can find additional admin notes on this, I would really appreciate it. 

 

Thank you!! 

Hi,

 

we have 2 fields - SRQ_AGREED_TIME and SRQ_AGREED_TIME_OLD

for some purposes we need to save old value to SRQ_AGREED_TIME_OLD when SRQ_AGREED_TIME is changed.

 

 

i wrote trigger:

 

trigger SRq_agreed_time_save_old_value on Case (before update) {

  Case[] item_old = Trigger.old;

  Case[] item_new = Trigger.new;

 

  for ( Case item : item_new)

  {

    if (item_old[0].SRq_agreed_time__c != null)

    {

      item.SRq_agreed_time_old__c = item_old[0].SRq_agreed_time__c;

    }

  }

}

 

 

and test method: 

 

@isTest

private class Srq_agreed_time_tests {

 

  static testMethod void beforeUpdateCase() {

  test.starttest();

  Case[] cases = [Select id, SRq_agreed_time__c from Case where Case.Status != 'Closed'];

 

  for(Case item : cases)

  {

    item.SRq_agreed_time__c = DateTime.now();

    }

 

      test.stoptest();

    }

}

 

 

I don't know If I don't understand how to write test methods but I read article about writing more times.

Please help me or tell me som secrets :) how to edit it and successfuly deploy trigger to server??

 

thank you

 

  • September 29, 2009
  • Like
  • 0

Goal: use a trigger to update a custom field on the Task (OppNumber) with a field on the Opportunity that is selected in the WhatID field (if an Opp is selected)

 

I thought this would be easy to do using a lookup and just passing the value, but you apparently cannot create a lookup on the Activity/Task object. 

 

I know I can pull in the record ID for the opp related via the WhatID field, but how can I refer to a specific field on that record? (Such as the Opportunity Number).

 

Open to suggestions.