• John Westenhaver
  • 30 Points
  • Member since 2014
  • Architect

  • Chatter
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 6
When we enable advanced currency feature, is it effect for currency fields on the child object of the opportunity object?
Hi all,

I have a test class where in i am trying to insert the test record but i doubt on they are being inserted properly

below is my code

public class VisitHandler_Test
 //create test data
    static testMethod void createTestData()
        Account acc=new Account(Name='Test Account',Channel__c='On-trade',
                                                   Premise_Type__c='Brown Café');
       	insert acc; 
        List<POSItemAccountLink__c> posLst=new List<POSItemAccountLink__c>();
        POSItem__c posItem=new POSItem__c(name='test item',type__c='Killer Item');
        insert posItem;
        for(Integer i=0;i<2;i++)
            POSItemAccountLink__c pos=new POSItemAccountLink__c();
        insert posLst;
        System.assertEquals(posItem.Name,'test item');

Also i have mentioned an asset statement to check if the record is inserted successfully or no
but i dont know how do i check whether that asset statement is executed successfully or no as it does not appear in the logs

Any help would be appreciated

When we enable advanced currency feature, is it effect for currency fields on the child object of the opportunity object?
Contacts have a lookup relationship to a custom Worker__c object.

Whenever a new Worker__c record is created, I want to create an associated (child) Contact.

My code is as follows:

trigger NewContactforWorker on Worker__c (after insert) {
	List<Contact> conList = new List<Contact>;
    for (Worker__c wkr : trigger.new) {
        a = new Contact(Worker__c = wkr.Id, FirstName = wkr.First_Name__c, 
                        LastName = wkr.Last_Name__c, QSAC_external_id__c = wkr.Worker_External_ID__c);
    insert conList;

But I get an error in between the second and third lines.  Can anyone help?

Thank you.
  • September 23, 2014
  • Like
  • 0
Hi Guys,

Can any one help me with how to enter the Date of Birth in MM/DD/YYYY format since the default it is taking it as DD/MM/YYYY

I have a trigger and a test class to upsert account team and account team share when a new records is added/edited on a custom object.

The trigger works, the test class failes on the accountshare piece, if I comment that out it works fine for the account team.  But the user gets added with read only.

Without changing system wide sharing rules is there a way to bypass this with a trigger?

Thank you,
Can anyone tell me where is this error occuring as Everytime a user edits their opportunity value after they set their deal to Award Close 100% according to the opportunity history, a new asset is created for each value edit that is shown in the opportunity history section.

By this Assets are creating multiple times at account object.

trigger CreateAssetonClosedWon on Opportunity (after insert, after update) {
     for(Opportunity o: trigger.new){
      if(o.isWon == true && o.HasOpportunityLineItem == true){
         String opptyId = o.Id;
         OpportunityLineItem[] OLI = [Select UnitPrice, Quantity, PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Description, Converted_to_Asset__c 
                                      From OpportunityLineItem
                                      where OpportunityId = :opptyId  and Converted_to_Asset__c = false];
       List<Asset> ast = new List<Asset>();
      /*  Asset[] ast = new Asset[]{}; */
         Asset a = new Asset();
         for(OpportunityLineItem ol: OLI){
            a = new Asset();
        a.AccountId = o.AccountId;
            a.Product2Id = ol.PricebookEntry.Product2Id;
            a.Quantity = ol.Quantity;
            a.Price =  ol.UnitPrice;
            a.PurchaseDate = o.CloseDate;
            a.Status = 'Purchased';
            a.Description = ol.Description;
            a.Name = ol.PricebookEntry.Product2.Name;
            ol.Converted_to_Asset__c = true;
      update OLI;
      insert ast;