• Mattwest
  • NEWBIE
  • 15 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 11
    Replies
Hello all,
I'm having a hard time grasping this concept. I've struggled through a few test classes based on creating new records. I'm trying to learn by example, and I just need help. Can someone show me what a test class for this trigger might look like. And if you have time, tell me why it works. Thanks in advance for your help!
trigger ReassignCall on Service_call__c (before insert, before update) {
    for (service_call__c sc: Trigger.new) {
        if (sc.assigned_to__c != null) {
            sc.OwnerId = sc.assigned_to__c;
            sc.assigned_to__c = null;
        }
    }
}

 
I'm using Object Converter (https://appexchange.salesforce.com/apex/listingDetail?listingId=a0N30000003JeOiEAK) to convert from a custom object called Service_Call__c to another custom object. I'm trying to use the documentation which only gives the following as a guide:
global static sObject OBJCNVTR__SmartEngine.Convert(sObject oSObject, string s
trMID){}
I got some help (because I'm not very experienced) and they came back with the following, but told me that it was odd to have the global static and the method call on the same line. Anyway, can anyone help me out?
trigger SCconvert on Service_Call__c (after update) {
	
    list<id> Service_CallId = new list<id>();
     for(Service_Call__c sc: trigger.new){
     if(sc.Release__c == true
        
         global static sObject OBJCNVTR__SmartEngine.Convert(sObject Service_Call__c, string SC_Conversion){}
     } 
}

 

Hello all,

I am learning apex, and have written several triggers. I thought I had figured out how to write a good test class, but unfortunately I did not. Can anyone tell me what I'm doing wrong?

 

My Trigger:

1
2
3
4
5
6
7
8 trigger scUpdate on Service_Call__c(before insert, before update){
    gii__SystemPolicy__c gii = [Select Mileage_Rate__c, Travel_Rate_Base__c, Travel_Rate__c from gii__SystemPolicy__c limit 1];
    for(Service_Call__c  sc : trigger.new){
        sc.Mileage_Rate__c = gii.Mileage_Rate__c;
        sc.Travel_Base__c = gii.Travel_Rate_Base__c;
        sc.Travel_Rate__c = gii.Travel_Rate__c;
    }
}

 

My Test Class: (not working)

1
2
3
4
5
6
7 @isTest 
private class TestscUpdate {
    static testMethod void insertNewCall() {
      Service_Call__c call = new Service_Call__c();
      insert call;
   }
}

 

The error: 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, scUpdate: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.scUpdate: line 2, column 1: []

Hello All,

I have been doing a lot of research, and have had no luck finding an answer. I am new to visualforce and could use any help you might have to offer. 

 

I am wanting an action on a task that pulls up a mobile visualforce page that will capture a signature and save it as an attachment to the record. 

 

I'm wanting to use Signature Pad similar to this: https://github.com/szimek/signature_pad

 

I've looked into some of the signature captures apps in the appexchange, but I don't need signatures on the level (or price) that most of them offer. I am just tyring to get a very simple sig capture.

 

Any help would be much appreciated.

Hello All,

I have been doing a lot of research, and have had no luck finding an answer. I am new to visualforce and could use any help you might have to offer. 

 

I am wanting an action on a task that pulls up a mobile visualforce page that will capture a signature and save it as an attachment to the record. 

 

I'm wanting to use Signature Pad similar to this: https://github.com/szimek/signature_pad

 

I've looked into some of the signature captures apps in the appexchange, but I don't need signatures on the level (or price) that most of them offer. I am just tyring to get a very simple sig capture.

 

Any help would be much appreciated.

Hello All,

I am new to Apex and I am trying to build a trigger that will pull field values from a single record in a custom object called system_policy__c. There is only one record for that object and it is intended to set default values for new records created. 

 

So basically I'm trying to pull a lookup field value from system_policy__c.field1__c to sample_object__c.field1__c

 


I'm trying to populate these fields (before insert,before update)

 

I am just learning, and any help will be much appreciated!!! Thanks in advance for any help you may be able to give!

Hello all,
I'm having a hard time grasping this concept. I've struggled through a few test classes based on creating new records. I'm trying to learn by example, and I just need help. Can someone show me what a test class for this trigger might look like. And if you have time, tell me why it works. Thanks in advance for your help!
trigger ReassignCall on Service_call__c (before insert, before update) {
    for (service_call__c sc: Trigger.new) {
        if (sc.assigned_to__c != null) {
            sc.OwnerId = sc.assigned_to__c;
            sc.assigned_to__c = null;
        }
    }
}

 
I'm using Object Converter (https://appexchange.salesforce.com/apex/listingDetail?listingId=a0N30000003JeOiEAK) to convert from a custom object called Service_Call__c to another custom object. I'm trying to use the documentation which only gives the following as a guide:
global static sObject OBJCNVTR__SmartEngine.Convert(sObject oSObject, string s
trMID){}
I got some help (because I'm not very experienced) and they came back with the following, but told me that it was odd to have the global static and the method call on the same line. Anyway, can anyone help me out?
trigger SCconvert on Service_Call__c (after update) {
	
    list<id> Service_CallId = new list<id>();
     for(Service_Call__c sc: trigger.new){
     if(sc.Release__c == true
        
         global static sObject OBJCNVTR__SmartEngine.Convert(sObject Service_Call__c, string SC_Conversion){}
     } 
}

 

Hello all,

I am learning apex, and have written several triggers. I thought I had figured out how to write a good test class, but unfortunately I did not. Can anyone tell me what I'm doing wrong?

 

My Trigger:

1
2
3
4
5
6
7
8 trigger scUpdate on Service_Call__c(before insert, before update){
    gii__SystemPolicy__c gii = [Select Mileage_Rate__c, Travel_Rate_Base__c, Travel_Rate__c from gii__SystemPolicy__c limit 1];
    for(Service_Call__c  sc : trigger.new){
        sc.Mileage_Rate__c = gii.Mileage_Rate__c;
        sc.Travel_Base__c = gii.Travel_Rate_Base__c;
        sc.Travel_Rate__c = gii.Travel_Rate__c;
    }
}

 

My Test Class: (not working)

1
2
3
4
5
6
7 @isTest 
private class TestscUpdate {
    static testMethod void insertNewCall() {
      Service_Call__c call = new Service_Call__c();
      insert call;
   }
}

 

The error: 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, scUpdate: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.scUpdate: line 2, column 1: []

Hello All,

I have been doing a lot of research, and have had no luck finding an answer. I am new to visualforce and could use any help you might have to offer. 

 

I am wanting an action on a task that pulls up a mobile visualforce page that will capture a signature and save it as an attachment to the record. 

 

I'm wanting to use Signature Pad similar to this: https://github.com/szimek/signature_pad

 

I've looked into some of the signature captures apps in the appexchange, but I don't need signatures on the level (or price) that most of them offer. I am just tyring to get a very simple sig capture.

 

Any help would be much appreciated.

Hello All,

I am new to Apex and I am trying to build a trigger that will pull field values from a single record in a custom object called system_policy__c. There is only one record for that object and it is intended to set default values for new records created. 

 

So basically I'm trying to pull a lookup field value from system_policy__c.field1__c to sample_object__c.field1__c

 


I'm trying to populate these fields (before insert,before update)

 

I am just learning, and any help will be much appreciated!!! Thanks in advance for any help you may be able to give!

Hey guys so im trying to use SignaturePad ......http://thomasjbradley.ca/lab/signature-pad/#howto .........into a visualforce page and im having some trouble getting the canvas element to work with apex/VF. i would really appricate some help with this i am a novice at VF and html so any help at all will probably be a lot 

Has anyone auto generated opportunity line items from a custom field in Opportunity.

 

Ex. Custom Field in Opportunity is linearfeet__c ; want to automatically insert 5 different product line items that are standard and use linearfeet__c in the quantity calculation?

 

I am working off of http://blog.jeffdouglas.com/2009/02/13/enhancing-the-lead-convert-process-in-salesforce/ as a starting point but lost.

 

Any help would greatly be appreciated.

 

Matt

Hi,

 

I need help on building a trigger to add the line items automatically based on a field, where the number is mentioned. As per that number the line items is created automatically. Please find the code for reference which I am working on:

 

trigger OpportunityProductInsert on Opportunity (after insert, after update){

                //USE DESCRIBE METHODS INSTEAD OF SOQL TO GET RECORDTYPEIDS. HELPS IN REDUCING DMLS

 

    Schema.DescribeSObjectResult d = Schema.SObjectType.Opportunity;

    Map<String,Schema.RecordTypeInfo> rtMapByName = d.getRecordTypeInfosByName();

    Id oppRTID = rtMapByName.get('Insert Opp RecordTypeName Here').getRecordTypeId();

//USE MAPS AND LIST TO HOLD DATA

Map<Id,String> currencyisocodemap = new Map<Id, String>();                

    for(Opportunity o :Trigger.new){

                if(o.CurrencyISOCode!=null){

                                currencyisocode.put(o.id, o.CurrencyISOCode);

                }

 

 

    }

//USE RELATIONSHIP QUERIES TO REDUCE SOQLS

 

List<PricebookEntry> pbe = [select Id, CurrencyISOCode from PriceBookEntry where CurrencyISOCode in :currencysiocodemap.keyset() and Pricebook2.isActive = true];

 

Map<String,String> isomap = new Map<String, String>();

 

for(PricebookEntry p  :pbe){

                isomap.put(p.CurrencyISOCode. p.Id);

 

}

 

List<OpportunityLineItem> oppline = new List<OpportunityLineItem>();

 

    for(Opportunity o :Trigger.new){

                //USE LISTS TO HOLD RECORDS BEFORE DOING 'BULK' INSERT

                If(o.N__c>0 && o.RecordTypeId==OppRTId){

                                oppLine.add(new OpportunityLineItem(OpportunityId = o.id, UnitPrice = 0, Quantity = 1, PricebookEntryId = isomap.get(o.CurrencyISOCode));

 

 

 

 

                }

 

 

 

    }

//INSERT OUTSIDE FOR LOOP. BULK INSERT. REDUCE DMLS

if(oppline.size()!=0) insert oppline;

 

}

  • May 03, 2011
  • Like
  • 0