Skip to main content
2 of 3
added 905 characters in body

What are the parameters for saving a phone number field in Apex?

When I insert the Order record, the Order saves but the custom phone number field does not. What are the parameters for saving a phone number field in Apex?

Order o = new Order(AccountId = a.Id, OwnerId = UserInfo.getUserId(), Pricebook2Id = Test.getStandardPricebookId(),
            ShipToContactId = c.Id,
            Status = 'Active',
            EffectiveDate = Date.newInstance(DateTime.now().year(),DateTime.now().month(),DateTime.now().day()),
            Requested_Delivery_Date__c = Date.newInstance(DateTime.now().year(),DateTime.now().month(),DateTime.now().day() + 1),
            Date_Fulfilled__c = Date.newInstance(DateTime.now().year(),DateTime.now().month(),DateTime.now().day() + 1),
            Ship_to_Phone__c = '2345678901'
    );
    system.debug(o.Ship_to_Phone__c);
    insert o;
    system.debug(o.Ship_to_Phone__c);
    o = [SELECT Id, ShipToContact.LastName, Ship_to_Phone__c FROM Order WHERE ShipToContact.LastName = 'SwarbrickTest' LIMIT 1];
    system.debug(o);