function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eliezer Augusto Javier Bautista 7Eliezer Augusto Javier Bautista 7 

I have a Map with two categories, and I want to add a third one

This if a part of the code where if categories are 'ST' there's a calculation, and if they are  'NS'  there's another. I need to make it the following "If the categories = ST or MSF to have the same calculations.

              IF(productobj.Categories__c=='ST')
                {
                    strunitprice=productobj.Manual_Cost__c.setScale(2);
                    system.debug('strunitprice'+strunitprice);
                }
                ELSE
                {
                    strunitprice=pricebkenryobj.UnitPrice.setScale(2);
                }    
                 
                //Add Percent start
                if(productobj.Categories__c=='NS')
                {
                   //Product info
                saveERPDataDetail .put('prdname',string.valueOf(productobj.name));
                saveERPDataDetail .put('prdunitcost',string.valueOf(untprice));
                saveERPDataDetail .put('prdcat',string.valueOf(productobj.Categories__c));
Best Answer chosen by Eliezer Augusto Javier Bautista 7
HarshHarsh (Salesforce Developers) 
Hi Eliezer,
Do you want 2 conditions in the first IF  i.e 
IF(productobj.Categories__c=='ST')
                {
                    strunitprice=productobj.Manual_Cost__c.setScale(2);
                    system.debug('strunitprice'+strunitprice);
                }
                ELSE
                {
                    strunitprice=pricebkenryobj.UnitPrice.setScale(2);
                }
 
To make the categories ST or MSF have the same calculations, you can use the following code:
 
IF(productobj.Categories__c=='ST' || productobj.Categories__c=='MSF')
                {
                    strunitprice=productobj.Manual_Cost__c.setScale(2);
                    system.debug('strunitprice'+strunitprice);
                }
                ELSE
                {
                    strunitprice=pricebkenryobj.UnitPrice.setScale(2);
                }

Hope your query is answered.

Please mark it as Best Answer if the above information was helpful.

Thanks.
 

All Answers

HarshHarsh (Salesforce Developers) 
Hi Eliezer,
Do you want 2 conditions in the first IF  i.e 
IF(productobj.Categories__c=='ST')
                {
                    strunitprice=productobj.Manual_Cost__c.setScale(2);
                    system.debug('strunitprice'+strunitprice);
                }
                ELSE
                {
                    strunitprice=pricebkenryobj.UnitPrice.setScale(2);
                }
 
To make the categories ST or MSF have the same calculations, you can use the following code:
 
IF(productobj.Categories__c=='ST' || productobj.Categories__c=='MSF')
                {
                    strunitprice=productobj.Manual_Cost__c.setScale(2);
                    system.debug('strunitprice'+strunitprice);
                }
                ELSE
                {
                    strunitprice=pricebkenryobj.UnitPrice.setScale(2);
                }

Hope your query is answered.

Please mark it as Best Answer if the above information was helpful.

Thanks.
 
This was selected as the best answer
Eliezer Augusto Javier Bautista 7Eliezer Augusto Javier Bautista 7
Thanks @harsh, I dont know why I forgot the OR Operator symbol haha, I'm the guy they're trying make a Developer. 
Worked like a charm