• Tibor
  • NEWBIE
  • 0 Points
  • Member since 2009

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

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

Hi,

 

i want to add some new information to self-service pages (View Cases tab). There is only Case number, Case subject and created date field. I want add here Case status field.

 

How ?

 

Where I can change this page?

 

thank you

  • August 28, 2009
  • Like
  • 0

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