• Christopher Picking
  • NEWBIE
  • 40 Points
  • Member since 2014
  • Salesforce Administrator/Developer
  • ADS, Inc.

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies
I want to restrict the following characters ‘ “ , * % @ and if possible remove any extra spaces at the end of the field. I've found validation rules for allowing characters but none for just restricting, I don't really want to have to input every single charachter other than those listed above. (infact when I try to do that I get syntax errors). Any guidence would greatly be appreciated.
Looking for help to get my test class working properly. The Code, Trigger, and Test class are listed below... Thanks in advance.
 
/*  TEST CLASS FOR QuoteTriggerHandler TO ASSESS HANDLING OF UPDATES TO
    BILL TO AND SHIP TO ACCOUNTS, CONTACTS, AND ADDRESSES

    - John Scardino, 2015-05-28
*/


@isTest     // test classes need the @isTest classification

private class QuoteTriggerHandlerTest {

    static testMethod void insertNewQuoteTest() {
        // select account to add a new opportunity towards
        Account newAccountJawn = new Account(Name='Jawn', Phone='(555) 555-5555',
            Customer_Class__c='Defense Industry', Entity_Type__c='Domestic');
        insert newAccountJawn;

        // create new opportunity on the account
        //      -> reference new op id on the new quote
        Opportunity newOpportunityJawn = new Opportunity(/*RecordType='Transactional Opportunity',*/CloseDate=date.Today(), StageName='Quoted', Name='Test Op', Account=[SELECT Id FROM Account WHERE Id= :[SELECT Id FROM Account WHERE Id= :newAccountJawn.Id]]);
        insert newOpportunityJawn;

        // create new contact on the account
        //      -> reference new contact id on the new quote
        Contact newContactJawn = new Contact(LastName='Aaron', Account=[SELECT Id FROM Account WHERE Id= :newAccountJawn.Id]);
        insert newContactJawn;

        // create new BILL TO address on the account
        //      -> reference new bill to address id on the new quote
        Address__c newBillingAddressJawn = new Address__c(Account_Name__c=[SELECT Id FROM Account WHERE Id= :newAccountJawn.Id],
            Address_Line_1__c='Apple Inc.', Address_Line_2__c='1 Infinite Loop', City__c='Cupertino', State_Code__c='CA', Postal_Code__c='95014', Postal_Code_Extension__c='2083', Country_Code__c='US', Type__c='Billing');
        insert newBillingAddressJawn;

        // create new SHIP TO address on the account
        //      -> reference new ship to address id on the new quote
        Address__c newShippingAddressJawn = new Address__c(Account_Name__c=[SELECT Id FROM Account WHERE Id= :newAccountJawn.Id],
            Address_Line_1__c='621 Lynnhaven Pkwy', Address_Line_2__c='Ste 400', City__c='Virginia Beach', State_Code__c='VA', Postal_Code__c='23452', Country_Code__c='US', Type__c='Shipping');
        insert newShippingAddressJawn;

        // create new quote
        //      <- include new id values for lookup fields to opportunity, contact, bill to and ship to
        SBQQ__Quote__c newQuoteJawn = new SBQQ__Quote__c(SBQQ__Opportunity__c=[SELECT Id FROM Opportunity WHERE Id= :newOpportunityJawn.Id],
            SBQQ__Type__c='Quote', SBQQ__Status__c='Draft', Contract__c=[SELECT Id FROM Contract__c WHERE Id= :newContactJawn.Id],
            Bill_To_Address__c=[SELECT Id FROM Address__c WHERE Id= :newBillingAddressJawn.Id], Ship_To_Address__c=[SELECT Id FROM Address__c WHERE Id= :newShippingAddressJawn.Id], Bill_To_Contact__c=[SELECT Id FROM Contact WHERE Id= :newContactJawn.Id], Ship_To_Contact__c=[SELECT Id FROM Contact WHERE Id= :newContactJawn.Id], Bill_To_Account__c=[SELECT Id FROM Account WHERE Id= :newAccountJawn.Id], Ship_To_Account__c=[SELECT Id FROM Account WHERE Id= :newAccountJawn.Id]);
        insert newQuoteJawn;

        // inserting the above quote should have fired off the trigger to this point
        //      the following lines are verification steps to ensure the trigger worked correctly

        SBQQ__Quote__c quoteValuesTest = [SELECT Id, Bill_To_Contact_Name__c, Ship_To_Contact_Name__c,
            Bill_To_Account_Name__c, Ship_To_Account_Name__c, SBQQ__BillingStreet__c, Bill_To_Street_Line_2__c, SBQQ__BillingCity__c, SBQQ__BillingState__c, SBQQ__BillingPostalCode__c, SBQQ__BillingCountry__c, SBQQ__ShippingStreet__c, Ship_To_Street_Line_2__c, SBQQ__ShippingCity__c, SBQQ__ShippingState__c, SBQQ__ShippingPostalCode__c, SBQQ__ShippingCountry__c FROM SBQQ__Quote__c WHERE id= :newQuoteJawn.Id];

        // test contact name
        System.assert(quoteValuesTest.Bill_To_Contact_Name__c == newContactJawn.Name);
        System.assert(quoteValuesTest.Ship_To_Contact_Name__c == newContactJawn.Name);

        // test account name
        System.assert(quoteValuesTest.Bill_To_Account_Name__c == newAccountJawn.Name);
        System.assert(quoteValuesTest.Ship_To_Account_Name__c == newAccountJawn.Name);

        // test billing address information
        System.assert(quoteValuesTest.SBQQ__BillingStreet__c == newBillingAddressJawn.Address_Line_1__c);
        System.assert(quoteValuesTest.Bill_To_Street_Line_2__c == newBillingAddressJawn.Address_Line_2__c);
        System.assert(quoteValuesTest.SBQQ__BillingCity__c == newBillingAddressJawn.City__c);
        System.assert(quoteValuesTest.SBQQ__BillingState__c == newBillingAddressJawn.State_Code__c);
        System.assert(quoteValuesTest.SBQQ__BillingPostalCode__c == newBillingAddressJawn.Postal_Code__c && '-' && newBillingAddressJawn.Postal_Code_Extension__c);
        System.assert(quoteValuesTest.SBQQ__BillingCountry__c == newBillingAddressJawn.Country_Code__c);

        // test shipping address information
        System.assert(quoteValuesTest.SBQQ__ShippingStreet__c == newShippingAddressJawn.Address_Line_1__c);
        System.assert(quoteValuesTest.Ship_To_Street_Line_2__c == newShippingAddressJawn.Address_Line_2__c);
        System.assert(quoteValuesTest.SBQQ__ShippingCity__c == newShippingAddressJawn.City__c);
        System.assert(quoteValuesTest.SBQQ__ShippingState__c == newShippingAddressJawn.State_Code__c);
        System.assert(quoteValuesTest.SBQQ__ShippingPostalCode__c == newShippingAddressJawn.Postal_Code__c && '-' && newShippingAddressJawn.Postal_Code_Extension__c);
        System.assert(quoteValuesTest.SBQQ__ShippingCountry__c == newShippingAddressJawn.Country_Code__c);

    }
}

 
I'm looking for the best way to accomplish assigning a permmision set when a new user is created without me having to manually do it. I'd like to do this via flow/process builder but I'm not having luck with that. Anyone have any insite or suggestions on how to do this task?
This is my class, test class, and trigger. When I try to deploy to Production my trigger recieves 0% coverage. I'm a complete beginner and unable to figure this out, your help is greatly apprecitated. 

Class -
public with sharing class TaskTriggerHelper2 {

    public static void assignTaskType(List<Task> newTasks)
    {
        for(Task aTask : newTasks)
        {
            if(aTask.Subject.contains('Obtain Updated ADS Cost from Supplier'))
            {
                aTask.Type = 'Supplier Update Request';
            }
        }
    }
}

Test Class -
@isTest
public with sharing class TaskTriggerHelper2TEST{
    public static testMethod void testTaskTriggerHelper2TEST(){      
        list <task> newTasks = new list <task> ();
        task aTask = new task();
        atask.subject = 'Obtain Updated ADS Cost from Supplier';
        atask.Status = 'Not Started';    
        atask.Priority = 'Normal';
       
        insert newTasks;
    }   
}

Trigger -
trigger Task2 on Task (before insert)
{
if(Trigger.isBefore && Trigger.isInsert)
    {
        TaskTriggerHelper2.assignTaskType(Trigger.new);
    }
}
I need to have a user assigned in order to make this test class actually function. My actual class and trigger work as designed, but the test class fails because it requires a user to be present in order to work. Here is the code I have. I'm very new to apex and coding all together so I'm kinda stuck. 

@isTest
public with sharing class UpdateNCMOwnerHandlerTest
{
public static testMethod void testUpdateNCMOwnerHandler()
{
  List<Non_Conforming_Material__c> nonConformingMaterials = new List<Non_Conforming_Material__c>();
Non_Conforming_Material__c nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'In Process'); //#1
  nonConformingMaterials.add(nonConformingMaterial);
  nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'Resolution'); //#2
  nonConformingMaterials.add(nonConformingMaterial);
  insert nonConformingMaterials;
    }
}
My Trigger is a follows. I know this should properly be done by calling a method in a class via the trigger and in order to move this to production I need to have this in a class and then create the test class. I'm ultra new at all of this and really appreciate any help that you can provide. 

trigger UpdateNCMOwner on Non_Conforming_Material__c (before insert, before update) {
            for(Non_Conforming_Material__c n : Trigger.new){
                if(n.NCM_Stage__c == 'In Process'){
                   n.OwnerID = n.NCM_Supplier_Buyer_ID__c;
                }
                else if (n.NCM_Stage__c == 'Resolution'){
                       n.OwnerID = n.NCM_Created_By_ID__c;
                }
             }
}
I'm looking for the best way to accomplish assigning a permmision set when a new user is created without me having to manually do it. I'd like to do this via flow/process builder but I'm not having luck with that. Anyone have any insite or suggestions on how to do this task?
This is my class, test class, and trigger. When I try to deploy to Production my trigger recieves 0% coverage. I'm a complete beginner and unable to figure this out, your help is greatly apprecitated. 

Class -
public with sharing class TaskTriggerHelper2 {

    public static void assignTaskType(List<Task> newTasks)
    {
        for(Task aTask : newTasks)
        {
            if(aTask.Subject.contains('Obtain Updated ADS Cost from Supplier'))
            {
                aTask.Type = 'Supplier Update Request';
            }
        }
    }
}

Test Class -
@isTest
public with sharing class TaskTriggerHelper2TEST{
    public static testMethod void testTaskTriggerHelper2TEST(){      
        list <task> newTasks = new list <task> ();
        task aTask = new task();
        atask.subject = 'Obtain Updated ADS Cost from Supplier';
        atask.Status = 'Not Started';    
        atask.Priority = 'Normal';
       
        insert newTasks;
    }   
}

Trigger -
trigger Task2 on Task (before insert)
{
if(Trigger.isBefore && Trigger.isInsert)
    {
        TaskTriggerHelper2.assignTaskType(Trigger.new);
    }
}
I need to have a user assigned in order to make this test class actually function. My actual class and trigger work as designed, but the test class fails because it requires a user to be present in order to work. Here is the code I have. I'm very new to apex and coding all together so I'm kinda stuck. 

@isTest
public with sharing class UpdateNCMOwnerHandlerTest
{
public static testMethod void testUpdateNCMOwnerHandler()
{
  List<Non_Conforming_Material__c> nonConformingMaterials = new List<Non_Conforming_Material__c>();
Non_Conforming_Material__c nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'In Process'); //#1
  nonConformingMaterials.add(nonConformingMaterial);
  nonConformingMaterial = new Non_Conforming_Material__c(NCM_Stage__c = 'Resolution'); //#2
  nonConformingMaterials.add(nonConformingMaterial);
  insert nonConformingMaterials;
    }
}