• James Swanson
  • NEWBIE
  • 0 Points
  • Member since 2020

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

I wanted to create a formula field that calculates the number of words (or characters) in a long text area, but I see that Salesforce does not have this capability. But I hear that apex can accomplish this? Sadly, I am not good with apex code, but I'm wondering if someone has any ideas on how to draft this code? Here are the specifics I am working with:

  • Calculate number of words (or characters) of field Testimony__c on Custom Object TargetX_SRMb__Essay__c and display results in field Testimony_Word_Count__c (also on Custom Object TargetX_SRMb__Essay__c).
I have a trigger that will prevent me from deleting a contact within my org but can't push it into production without a test class. I am new to triggers and am not entirely sure how to write a test class for the following code:

trigger RestrictConDels on Contact (before delete) {
    if (Trigger.isDelete && Trigger.isBefore) {
    //In a before delete trigger, the trigger accesses the records that will be deleted with the Trigger.old list.
        for (Contact a : Trigger.old) {
            if (a.name != 'okToDelete') {
                system.debug('Record: '+a.name+' failed to delete');
                a.addError('You can\'t delete this record!');
                continue;
            }
            system.debug('Successfully Deleted Record: '+a.name);
        }
    }
}


Any help is appreciated. 

Hi,

 

  I have a basic new sobject as an example called essay__c with one field called name__c.

 

I'd like to have a custom button on the accounts tab that when pressed creates a new essay record. I'm trying thew following code in the button but it doesn't work:

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var t1= new sforce.SObject("essay__c "); t1.name__c = "jim";

var result = sforce.connection.create([t1]);

 

It's probably something really stupid. Does anyone know why please?

 

Thanks,

James.