• Bill_Pomeroy
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies

As a followup to my previous posts (Again, many many thanks) I am still having trouble with the trigger.

The code seems to function and I created a test class and the code itself is 100% covered.

The Trigger will not work, I am getting 0% coverage and I am not sure what I am doing wrong.

Trigger:

trigger FirmwareTrigger on Customer_Asset__c (before update, after update) {        
     FirmwareClass helper = new FirmwareClass();        
       helper.createCases(Trigger.new);        
} 

Test Class

@isTest
private class FirmwareClassTest {
   private static testMethod void testCreateCases() {
    //create a new instance of a Customer_Asset__c to use in the test
    List<Customer_Asset__c> testAssets = new List<Customer_Asset__c> {};
    Customer_Asset__c ta = new Customer_Asset__C();
    ta.Firmware_Update_Available__c = True;
    testAssets.add(ta);

    FirmwareClass helper = new FirmwareClass();
    Test.startTest();
    helper.createCases(testAssets);
    Test.stopTest();

    // query for cases to see if some were created and do an assertion
}
Customer_Asset__c[] acctQuery = [SELECT Firmware_Update_Available__c FROM Customer_Asset__c];

Class

public with sharing class FirmwareClass{

   public void createCases(List<Customer_Asset__c> assets){
    List<Case> casesToCreate = new List<Case>();

   for(Customer_Asset__c acc:assets){
      if (acc.Firmware_Update_Available__c == TRUE){
      Case caseToAdd = new Case();
      caseToAdd.AccountId = acc.Account__c;
      caseToAdd.Subject = 'Software Upgrade Available';
      casesToCreate.add(caseToAdd);
   }       
 } 
  if (casesToCreate.size() > 0)
  insert casesToCreate;
   }

   }

I tried to get fancy and added (what I hoped / thought) would be some sort of validation within the trigger.

Updated Trigger

trigger FirmwareTrigger on Customer_Asset__c (before update) {

 List<FirmwareUpdate> listfirm = new list<FirmwareUpdate>();
      for (Customer_Asset__c ta: trigger.new)
 {
  FirmwareUpdate firmup = [SELECT Firmware_Update_Available__c FROM Customer_Asset__c];
if (firmup == 1)
{
       FirmwareClass helper = new FirmwareClass();
       for (Customer_Asset__c az: Trigger.new);
        helper.createCases(Trigger.new);
      }
}
}

I receive a compile error with the New Trigger:

Error: Compile Error: Invalid type: FirmwareUpdate at line 3 column 47

The old trigger compiles but is showing a 0 code coverage.   At this point I am stuck.  I believe my class works, but I can't get past this point.

Hi Everyone,


Our company manufactures equipment that occasionally requires software updates.   What we want to do is the following:


Intent:  Create an automatic process that generates cases based on Customer Asset and Firmware Version.


Current setup:

Object named Firmware Version
Object named Firmware Update Available
E-mail Template - Software Update (includes Update Revision Notes, Update File, Instructions to implement)

Current Workflow:

Checks Object - Firmware Update Available and Verifies current Firmware Version < New Version Number

If True -> E-mail Notification sent out to customer(s) with attachments.

Task Created under Instrument that requests Service open a ticket.


What we need:

Case is created for each separate asset for each customer.
E-mail Template that is sent from case includes all relevant information and attachments.
Customers then respond to case (via email2case) that update is complete.


Roadblock:

No "Out of the Box" App that can generate a case from workflow, task, or asset.

Help Requested:

Does anyone have a visualforce or javascript they have used that does this?  Alternately, can someone point me in the right direction to create this functionality?

Hi Everyone,

 

Thank you for taking the time to read this.   I am new to salesforce, visualforce and apex and am hoping that someone on the board can at least point me in the right direction for what I am attempting to do.

 

 

Intent:

1) Go to Customer Assets Tab

2) From Search list, select multiple accounts.

3) Click on a button labeled "Update Build Version"

4) From a picklist, change the version from x to y.

5) Save.

6) Selected Assets Build Version changed.

 

I started to look through the visualforce documentation but I can't seem to find what I am looking for.

 

I attempted to customize the code from:

http://www.salesforce.com/us/developer/docs/fundamentals/Content/adg_composite_app_create_mass_update_try_it_out.htm

 

I can see how it is supposed to work, but I know that I am missing several steps.  

 

Field Label: Build / Mod / Version

Object Name:  Customer Asset

Field Name: Mod_Version

Data Type: Picklist

API Name:  Mod_Version__c

As a followup to my previous posts (Again, many many thanks) I am still having trouble with the trigger.

The code seems to function and I created a test class and the code itself is 100% covered.

The Trigger will not work, I am getting 0% coverage and I am not sure what I am doing wrong.

Trigger:

trigger FirmwareTrigger on Customer_Asset__c (before update, after update) {        
     FirmwareClass helper = new FirmwareClass();        
       helper.createCases(Trigger.new);        
} 

Test Class

@isTest
private class FirmwareClassTest {
   private static testMethod void testCreateCases() {
    //create a new instance of a Customer_Asset__c to use in the test
    List<Customer_Asset__c> testAssets = new List<Customer_Asset__c> {};
    Customer_Asset__c ta = new Customer_Asset__C();
    ta.Firmware_Update_Available__c = True;
    testAssets.add(ta);

    FirmwareClass helper = new FirmwareClass();
    Test.startTest();
    helper.createCases(testAssets);
    Test.stopTest();

    // query for cases to see if some were created and do an assertion
}
Customer_Asset__c[] acctQuery = [SELECT Firmware_Update_Available__c FROM Customer_Asset__c];

Class

public with sharing class FirmwareClass{

   public void createCases(List<Customer_Asset__c> assets){
    List<Case> casesToCreate = new List<Case>();

   for(Customer_Asset__c acc:assets){
      if (acc.Firmware_Update_Available__c == TRUE){
      Case caseToAdd = new Case();
      caseToAdd.AccountId = acc.Account__c;
      caseToAdd.Subject = 'Software Upgrade Available';
      casesToCreate.add(caseToAdd);
   }       
 } 
  if (casesToCreate.size() > 0)
  insert casesToCreate;
   }

   }

I tried to get fancy and added (what I hoped / thought) would be some sort of validation within the trigger.

Updated Trigger

trigger FirmwareTrigger on Customer_Asset__c (before update) {

 List<FirmwareUpdate> listfirm = new list<FirmwareUpdate>();
      for (Customer_Asset__c ta: trigger.new)
 {
  FirmwareUpdate firmup = [SELECT Firmware_Update_Available__c FROM Customer_Asset__c];
if (firmup == 1)
{
       FirmwareClass helper = new FirmwareClass();
       for (Customer_Asset__c az: Trigger.new);
        helper.createCases(Trigger.new);
      }
}
}

I receive a compile error with the New Trigger:

Error: Compile Error: Invalid type: FirmwareUpdate at line 3 column 47

The old trigger compiles but is showing a 0 code coverage.   At this point I am stuck.  I believe my class works, but I can't get past this point.

Hi Everyone,


Our company manufactures equipment that occasionally requires software updates.   What we want to do is the following:


Intent:  Create an automatic process that generates cases based on Customer Asset and Firmware Version.


Current setup:

Object named Firmware Version
Object named Firmware Update Available
E-mail Template - Software Update (includes Update Revision Notes, Update File, Instructions to implement)

Current Workflow:

Checks Object - Firmware Update Available and Verifies current Firmware Version < New Version Number

If True -> E-mail Notification sent out to customer(s) with attachments.

Task Created under Instrument that requests Service open a ticket.


What we need:

Case is created for each separate asset for each customer.
E-mail Template that is sent from case includes all relevant information and attachments.
Customers then respond to case (via email2case) that update is complete.


Roadblock:

No "Out of the Box" App that can generate a case from workflow, task, or asset.

Help Requested:

Does anyone have a visualforce or javascript they have used that does this?  Alternately, can someone point me in the right direction to create this functionality?

Hi Everyone,

 

Thank you for taking the time to read this.   I am new to salesforce, visualforce and apex and am hoping that someone on the board can at least point me in the right direction for what I am attempting to do.

 

 

Intent:

1) Go to Customer Assets Tab

2) From Search list, select multiple accounts.

3) Click on a button labeled "Update Build Version"

4) From a picklist, change the version from x to y.

5) Save.

6) Selected Assets Build Version changed.

 

I started to look through the visualforce documentation but I can't seem to find what I am looking for.

 

I attempted to customize the code from:

http://www.salesforce.com/us/developer/docs/fundamentals/Content/adg_composite_app_create_mass_update_try_it_out.htm

 

I can see how it is supposed to work, but I know that I am missing several steps.  

 

Field Label: Build / Mod / Version

Object Name:  Customer Asset

Field Name: Mod_Version

Data Type: Picklist

API Name:  Mod_Version__c