• Max75
  • NEWBIE
  • 15 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi guys.

I'm struggling with a formula:

IF( Sales_Company__c = "FI", MID(ProductCode, 4, 12), ProductCode)

Now I need to add in another parameter in Sales Company. It should be both A1 and FI. 

I think I'm blanking out here.
  • September 12, 2019
  • Like
  • 0
Hi all,

I'm new to Apex but have been tasked with making one small change to an old Apex Class.
 
public with sharing class WorkDetailUtilities
{
    public static List<SVMXC__Service_Order_Line__c> AddWorkDetails(SVMXC__Service_Order__c WorkOrder, WorkDetailUtilities.FSGCart FSGCart, 
                                Id WorkDetailRTId, List<FSGItemWrapper> MissingCartItems, Id WorkDetailId) 
    {
        system.debug(LoggingLevel.INFO, 'WorkOrder: ' + WorkOrder + ', FSGCart: ' + FSGCart + ', WorkDetailRTId: ' + WorkDetailRTId + ', WorkDetailId: ' + WorkDetailId);
        List<SVMXC__Service_Order_Line__c> WorkOrderLines = new List<SVMXC__Service_Order_Line__c>();
        Map<String, WorkDetailUtilities.FSGItemWrapper> mapPartQuantity = new Map<String, WorkDetailUtilities.FSGItemWrapper>();
        String STDWorkshopHoursProductCode = Label.STD_Workshop_Hours_Product_Code;
        SVMXC__Service_Order_Line__c PSWorkDetail;
        
        try 
        {
            for(WorkDetailUtilities.FSGItemWrapper FSGCartItem :FSGCart.CartItems) 
            {
                system.debug(LoggingLevel.INFO, 'FSGCartItem: ' + FSGCartItem);
                if (FSGCartItem.Part != STDWorkshopHoursProductCode && !FSGCartItem.Part.contains('-'))
                {
                    mapPartQuantity.put('00-' + FSGCartItem.Part, FSGCartItem);
                }
                else
                {
                    mapPartQuantity.put(FSGCartItem.Part, FSGCartItem);
                }    
            }
            system.debug(LoggingLevel.INFO, 'mapPartQuantity: ' + mapPartQuantity);
            
            if (String.isNotBlank(WorkDetailId))
            {
                PSWorkDetail = [SELECT Id, SVMXC__Serial_Number__c, SVMX_Line_Branch_Code__c FROM SVMXC__Service_Order_Line__c WHERE Id =:WorkDetailId];
            }
            system.debug(LoggingLevel.INFO, 'PSWorkDetail: ' + PSWorkDetail);
            
            List<Product2> lstProducts = new List<Product2>([SELECT Id, ProductCode, Name,SVMX_Extra_Description__c,SVMXC__Product_Cost__c FROM Product2 WHERE ProductCode IN :mapPartQuantity.keySet() 
                        AND SMVX_Sales_Company__c =:WorkOrder.SVMXC__Company__r.SVMX_Sales_Company__c AND IsActive = true]);
            system.debug(LoggingLevel.INFO, 'lstProducts: ' + lstProducts);
The change should be (where marked in bold) that instead of '00-' being added it should take the value from the field prefix__c on the Product object. If I add that in instead like: 

mapPartQuantity.put(prefix__c + FSGCartItem.Part, FSGCartItem);

I get the error Error: Compile Error: Variable does not exist: prefix__c at line 19 column 41. 

I guess I need to add that field in somewhere before, but where?

Any help will be much appreciated.
  • June 17, 2019
  • Like
  • 0
Hi guys.

I'm struggling with a formula:

IF( Sales_Company__c = "FI", MID(ProductCode, 4, 12), ProductCode)

Now I need to add in another parameter in Sales Company. It should be both A1 and FI. 

I think I'm blanking out here.
  • September 12, 2019
  • Like
  • 0