• GauravGarg
  • PRO
  • 2660 Points
  • Member since 2015
  • Salesforce Developer
  • Unicolum / Rightpoint


  • Chatter
    Feed
  • 87
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 6
    Questions
  • 880
    Replies
HI All,

can anyone provide me a solution on how to update the ownerId field in the ContentDocument object. i have tried doing this with a trigger on ContentDocument object but it does not seems to work
Hi,

I have this trigger that I would like to convert to an apex class and I would like to add some code to the class.  The trigger changes contacts to the account owner id when the account owner is changed.  What I would like to add is something that also changes the contact owner when a contact is created or added to the account.

Here is the trigger I have.

trigger AlignContactownertoAccountOwner on Account (after insert,after update) {
      Set<Id> accountIds = new Set<Id>();
      Map<Id, String> oldOwnerIds = new Map<Id, String>();
      Map<Id, String> newOwnerIds = new Map<Id, String>();
      List<Contact> contactUpdates = new List<Contact>();
      for (Account a : Trigger.new)
      {
         if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
         {
            oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId);
            newOwnerIds.put(a.Id, a.OwnerId);
            accountIds.add(a.Id);

         }

      }

        if (!accountIds.isEmpty()) {

         for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])

            {

            String newOwnerId = newOwnerIds.get(acc.Id);
            String oldOwnerId = oldOwnerIds.get(acc.Id);

            for (Contact c : acc.Contacts)

            {

               if (c.OwnerId == oldOwnerId)
               {

               Contact updatedContact = new Contact(Id = c.Id, OwnerId = newOwnerId);

               contactUpdates.add(updatedContact);

               }

            }

             

            }

       }
            update contactUpdates;

}

Any help would be great.

Thanks,

Michael 
Hello Devs, I have the following Trigger and Class that was working fine until this morning when I received the following error of Too Many future calls: 51. 

Any idea how to alleviate gettign this error?  Here is my trigger and class code....thank you all for any help you can provide....

Trigger:
 
trigger DeleteExtraBookingsTrigger on Opportunity (after insert) {

    For(Opportunity opps : Trigger.new){
        If(opps.Auto_Bookings__c == True){
            
            
        DeleteExtraBookingsClass.deleteRecords(Trigger.newMap.keySet());    
            
        }
    }
    
    
}

Class code:
 
public class DeleteExtraBookingsClass {

    @future
    public static void deleteRecords(Set<ID> oppIdsToDelete){
        List<Opportunity> opp = [SELECT ID, Armor_Product_Category__c From Opportunity WHERE ID IN : oppIdsToDelete AND Auto_Bookings__c = True
                                AND (Armor_Product_Category__c = null or Armor_Product_Category__c = 'Armor | null')];
        
        If(opp.size()>0){
        delete opp;
        database.emptyRecycleBin(opp);
        }
    }
    
}

Hello everyone.
I have a requirement to store information from different Contacts in Google Drive. My problem is that I would like to create a directory dynamically for each new contact and I have not found much information on how to do it from apex. Has anyone had success performing this functionality?

Greetings thank you!
Hi,

The below trigger was fired after updating the field twice, but it was not fired before update.
 
trigger age on Account (before update) {

  Map<Id,Account> ageMap = new Map<Id,Account>(); 
  Account[] acct = [SELECT Id,Age__c FROM Account WHERE Id IN : Trigger.newMap.keySet()];
    
     for(Account a : trigger.new){
           

            if(a.age__c != null){
             
                ageMap.get(a.Id);
                a.Is_Age_Updated__c = true;
               
            }
            else{
                
             ageMap.get(a.Id);
             a.Is_Age_Updated__c = false;
            }                  
    }

}


 
  • February 02, 2018
  • Like
  • 0
Hi All,
          I have two objects called product and product details. Product field is lookup on product details.
          In product details object, if I have a product detail record pd1 with product p1, I shouldn't be able to create or update 
          another product detail pd2 with product p1.
         
           How can I achieve this?
What happens to the secondary master detail relationship if the primary master detail relationship is changed to lookup?
Hello,
I'm new to triggers and struggling with this. I need a trigger that pulls the Opportunity name and creates a new record in my custom object, AE Opp. I do not need it to create a lookup or link it to the opp, i just need it to create a whole new record so that I can create a task on it.. Is this feasible?
How to check whether two users are in the same queue in apex trigger?
  • January 08, 2018
  • Like
  • 0
Hello All,
I am an admin not a developer and I have written a simple before delete trigger and test class. The test is getting 80% coverage which is fine as I can deploy it, but for my own curiosity can anyone tell me how I can get 100% coverage please?

Thanks in advance

Trigger
trigger CheckGiftPledgeCount on Session__c (Before Delete) {
If(trigger.isBefore){
   If(Trigger.isDelete){
       for(Session__c a: trigger.old){
           if(a.TotalMembersRecruited__c>=1){
               a.adderror('You cannot delete a session if the count of total members recruited is greater than 0');
                 }
             }

        }
   }
}

Test Class
@isTest

private class CheckGiftPledgeCountTest{
     static testMethod void testTrigger(){
     Session__c ses = new Session__c() ;
     ses.Recruiter__c = '0035800000tXTlw';
     ses.Booking__c = 'a005800000K5yKl';

     insert ses;
     delete ses ;
     }
}

 
I am getting json data from an external webservice. The format of json data is as follows.
      Fullname=Michael$stone
      homephone=239923923 
I need to map the firstname and lastname to the Lead object standard fields.
so firstname=Michael and lastname=stone.

so my query is how to split the fulname in json data and then store into lead object fields.

Thanks
Smita B
 
Hello Team,
I want to add one more field to the below SOQL.  This field  "Name" is coming from a different Entity. Not sure how can I go about this

Field to add: Name   , Table: TBC_Verticals__c

SELECT Name,
    (SELECT UnitPrice FROM OpportunitylineItems) ,
    (SELECT Revenue__c FROM Opportunity_Line_Item_facts__r) ,
    FROM opportunity

  
Hi,
How can I align page block table title into centre

<apex:pageblock title="Main title"> 

title in page block want show in center, how to do this?
Please help me

Thanks in Advance
Hi all,

I am new in Salesforce and I need a bit of help.
We customize a field in a Dev Sandbox, we made it to show the total amount of the opportunities attached to an vehicle. And also created a triger that updates that value every time a value in the opportunty is changed. But now we need to move all of that to a different sandbox.
Can you please help me with how can we do that.
What tool can I use to do that?

Thank You,
Calin B.

 
Hi,
I have created the below tasks as scheduled actions under the Contract object, criteria is when the OP >0,
Now i want to autoclose the tasks under the criteria as,
- Trigger criteria not met anymore, or new payment failure task created
i.e when the OP <0  OR if "Notification " one is Open, and the "Final reminder" one get created then the " Notification" one should get closed. I couldnt determine how to do teh second part. Can you plz suggest.
Can i create this in teh same PB of task creation? ( The criteria is OP >0, then its creating the tasks on regular intervals).
Or Do i need to create another PB in any othr object ( Task ?). Thanks

User-added image
Hi All,
I have a visualforce page with list of orders. And there is a link "Request" for every order. When I click "Request" link, then order gets a status "Requested".
I need to create a validation rule: If there is already order with the status “Requested”, then the user got a message that there is another pending order. Could someone help with this? Thanks!
Hi guys,

Currently i'm looking into the implementation of a fill-in able table that is integrated an linked with 1 opportunity/record page. 
The table will need to be aproximatly the same as the image beneath:

User-added image

- Would it be able to create a VF template where i can link to from my opportunity page (each opportunity has his new VF page)?
- The VF would contain +/- 180 custom fields that need to be filled in on bulk and/or manual.
    - Do I need to create all these 180 custom field in SF? Are there other ways to not overconsume fields?

Could you guys please help me how I should tackle this one?
We need these variables to get a proper view on the incoming workload in our copmany. So reports will be generated on the based of these fields!

Thanks for your help!
Hello,

I have two account which have a certain Account hierarcy with them.

I want to put one of the account below the other, what impacts shoud i need to consider.
and where can i check technically for impacts if any
thanks for suggestion!
Hi All,

I am new to lightning. My requirement is to load external Minify javascript file which will run a demo or walkthru over the object records, Dashboard to enlight customer to use Lightning. 

Currently, the same has been working in salesforce classic, but in lightning it is not allowed and throwing error. 

Do anyone facing the same issue? 
My client require to have two way integration between Salesforce - Siebel. 

Is there any third party (app exchange) tool. 
Or we should go with customized code. 

Please suggest. 
I want to create Opportunity Share records for two custom fields "Manager" and "Senior Manager"  lookup to User on Opportunity object. 

My Batch job is working as expected and creating those record perfectly. 

But, the issue is in Test Class:
  • I have created one createOpportunity() method, and create two Opportunities. 
  • Both the opportunities have Manager / Senior Manager field populated with User. 
  • Now, when I run this method, It will cover my Batch job and create sharing records ( that I can debug in batch job).
  • If I am trying to query those sharing record in Test Class using below query, it is giving 0 records. 
  • SELECT Id, manager__c, senior_manager__c, rowcause from Opportunity. 
Any ideas please. 
We have some VF page, that we visible as Public Site on my client website. The VF page are working fine but due to salesforce Standard Javascripts. The website perform is quite down. 

Can you please provide me some idea to avoid running these standard Javascript libraries. 

 
Hi All,

I have completed my Lightning Superbadge two months ago and since then it is showing in active module. Please help me out how can I fix this. I already had contacted with salesforce trailhead but they are providing no help. 

Thanks,
Gaurav
Hi All,

Today I have completed my Lightning super badge module, still it is showing under Active module.

User-added image

Please suggest how can I fix this. 

Thanks,
Gaurav
HI All,

can anyone provide me a solution on how to update the ownerId field in the ContentDocument object. i have tried doing this with a trigger on ContentDocument object but it does not seems to work
Hi All
I have one requirement,In detail page edit and save buttons are Standard buttons and page is standard page. I created one vf page in same detail page.So my detail page one standard page and one Custom Visualforce page is there.But i want to create Custom Visualforce page instead of standard Vf page and combine both Vf pages into one page.How it possible?plz help me
Hi,

I have this trigger that I would like to convert to an apex class and I would like to add some code to the class.  The trigger changes contacts to the account owner id when the account owner is changed.  What I would like to add is something that also changes the contact owner when a contact is created or added to the account.

Here is the trigger I have.

trigger AlignContactownertoAccountOwner on Account (after insert,after update) {
      Set<Id> accountIds = new Set<Id>();
      Map<Id, String> oldOwnerIds = new Map<Id, String>();
      Map<Id, String> newOwnerIds = new Map<Id, String>();
      List<Contact> contactUpdates = new List<Contact>();
      for (Account a : Trigger.new)
      {
         if (a.OwnerId != Trigger.oldMap.get(a.Id).OwnerId)
         {
            oldOwnerIds.put(a.Id, Trigger.oldMap.get(a.Id).OwnerId);
            newOwnerIds.put(a.Id, a.OwnerId);
            accountIds.add(a.Id);

         }

      }

        if (!accountIds.isEmpty()) {

         for (Account acc : [SELECT Id, (SELECT Id, OwnerId FROM Contacts) FROM Account WHERE Id in :accountIds])

            {

            String newOwnerId = newOwnerIds.get(acc.Id);
            String oldOwnerId = oldOwnerIds.get(acc.Id);

            for (Contact c : acc.Contacts)

            {

               if (c.OwnerId == oldOwnerId)
               {

               Contact updatedContact = new Contact(Id = c.Id, OwnerId = newOwnerId);

               contactUpdates.add(updatedContact);

               }

            }

             

            }

       }
            update contactUpdates;

}

Any help would be great.

Thanks,

Michael 
Hi,

We are creating a cusotm VF form, which contains Account Name and Contact Name. On Click of Save button , Account , Contact  and opportunity should be created and Account and Contact  should be linked to opportunity.

Thanks.
Hello Devs, I have the following Trigger and Class that was working fine until this morning when I received the following error of Too Many future calls: 51. 

Any idea how to alleviate gettign this error?  Here is my trigger and class code....thank you all for any help you can provide....

Trigger:
 
trigger DeleteExtraBookingsTrigger on Opportunity (after insert) {

    For(Opportunity opps : Trigger.new){
        If(opps.Auto_Bookings__c == True){
            
            
        DeleteExtraBookingsClass.deleteRecords(Trigger.newMap.keySet());    
            
        }
    }
    
    
}

Class code:
 
public class DeleteExtraBookingsClass {

    @future
    public static void deleteRecords(Set<ID> oppIdsToDelete){
        List<Opportunity> opp = [SELECT ID, Armor_Product_Category__c From Opportunity WHERE ID IN : oppIdsToDelete AND Auto_Bookings__c = True
                                AND (Armor_Product_Category__c = null or Armor_Product_Category__c = 'Armor | null')];
        
        If(opp.size()>0){
        delete opp;
        database.emptyRecycleBin(opp);
        }
    }
    
}

I am trying to create a process where a case is created from and opportunity. 

IF the amount field is not populated on the opportunity, create a new case. 

All help is appreciated. 
I want to create a picklist in lightning (<lightning:select>) and the value for the options should be fetched from List custom Setting. How can we do this?
Thanks

 

I'm facing some trouble to GROUP BY a SELECT with 2 Child Objects. This is the following SELECT:
 
[SELECT Id AtendId, BI_BR_Adabas__c, BI_BR_Adabas__r.BI_BR_Parceiro__c, BI_BR_Cliente__c, BI_BR_Adabas__r.Modelo_de_Atuacao__c, BI_BR_Adabas__r.BI_BR_Parceiro__r.Name, BI_BR_Adabas__r.BI_BR_Parceiro__r.BI_No_Identificador_fiscal__c, BI_BR_Escopo_de_Produto__c, BI_BR_Adabas__r.BI_BR_Parceiro__r.BI_CAM_Codigo_del_cliente__c, BI_BR_Adabas__r.BI_BR_Parceiro__r.Codigo_Grupo__c, BI_BR_Adabas__r.Name AdabasName FROM BI_BR_Atendimento_Comercial_e_Carteira__c WHERE BI_BR_Cliente__c = :lCliente AND BI_BR_Adabas__r.BI_BR_Parceiro__c != null AND BI_BR_Excluir__c = false AND BI_BR_Adabas__r.Modelo_de_Atuacao__c = :lMod GROUP BY BI_BR_Adabas__c, BI_BR_Cliente__c]



The BI_BR_Atendimento_Comercial_e_Carteira__c Object repeats N times for the same BI_BR_Adabas__c for each BI_BR_Cliente__c and as I only need one record (all data will repeat N times because they are the same datas in multiple records)

To achieve this I'm trying to GROUP BY EACH Adabas on EACH Account(BI_BR_Cliente__c).

I'm getting the following error:
 
​Line: 1, Column: 14 Field must be grouped or aggregated: Id

 
Full requirement is as follow:

Objective
The Fixed Assets Management System - FAMS will help the Bank in maintaining the details of
Fixed Assets at all the Branches in a centralized database. The system will be a web portal where
the Branch Executive will enter the details of Fixed Assets purchased for the Branch. The system
will automatically calculate depreciation on the asset. The system will maintain repairs expenses
incurred on the asset and maintain track of re-pairs done on an asset. The system will update the
depreciated value of each asset and help the management in getting the category wise consolidated
depreciated value of all fixed assets through out the Bank and also at the Branch level. System will
changes the status of Fixed Asset as written off, when the depreciated value reaches zero.
Users of the system
Multiple profiles of users shall operate this system.
1. Administrator
2. Branch Manager
3. Bank Employee
4. Management Executive
5. Purchase Executive
High Level Requirements
1. System allows the registered user to login and provide role based access to system features /
functionality.
2. Management Executive create, update, delete various fixed assets categories, depreciation
methods for each category in the system and system maintains centralized data of it.
3. Bank Executives enters the new asset details purchased for the branch and system maintain the
data centrally.
4. Bank Executives enters the details of repairs expenses incurred on the asset.
5. System generates the Assets Repairs Expense Report.
6. Purchase Executive will access the system to get the Assets Repairs Report and use the same to
generate the vendor performance report based on the Asset Repairs Report.
7. System calculates depreciation on the assets annually based on the category and depreciation
method of the category.
8. Branch Manager and Management Executive will access the system to get various analytical
reports.
Hello everyone.
I have a requirement to store information from different Contacts in Google Drive. My problem is that I would like to create a directory dynamically for each new contact and I have not found much information on how to do it from apex. Has anyone had success performing this functionality?

Greetings thank you!
Hi,

The below trigger was fired after updating the field twice, but it was not fired before update.
 
trigger age on Account (before update) {

  Map<Id,Account> ageMap = new Map<Id,Account>(); 
  Account[] acct = [SELECT Id,Age__c FROM Account WHERE Id IN : Trigger.newMap.keySet()];
    
     for(Account a : trigger.new){
           

            if(a.age__c != null){
             
                ageMap.get(a.Id);
                a.Is_Age_Updated__c = true;
               
            }
            else{
                
             ageMap.get(a.Id);
             a.Is_Age_Updated__c = false;
            }                  
    }

}


 
  • February 02, 2018
  • Like
  • 0

Hello all guys,

Im so new in salesforce, trying to improve day by day. I have a problem and i need your help. Into the opportunity i need to send a custom note that when one agent want to send the opportunity to the approval process the approver could read this note. I need to do this because the agent cant apply discounts to the opportunity and this note is to explain to the approver why i have applyed this discounts. Can i do this? how?

Thank you guys!

Though I expect I can get record IDs of the custom object "AddtionalLabels__c" using javascript including AJAX called by onclick event on apex:panelGrid in Visualforce page, It does not work.(at Line 14)
The Vf page is below.
Line 10 does work.

How can I fix it? Or is there fatal mistake?
(Sorry for using crappy English.)

<Japanese>
お世話になります。
VisualforcePageで、apex:panelGridのonclickイベントでjavascriptを呼び出し、
javascriptからAjaxを利用してカスタムオブジェクト"AddtionalLabels__c"をクエリ取得しようとしています。
期待では下記コード14行目"alert(sobjects[i].Id);"のところでアラートが表示されると思ったのですが、されません。
問題点と解決策をご教示くださいますでしょうか。



----------------------------------------------------------------------------------
  1. <apex:page standardController="AddtionalLabels__c" extensions="AddLabelSettings,AdditionalLabelExtension" id="Page">
  2.     
  3.     
  4.     <script src="/soap/ajax/32.0/connection.js" type="text/javascript"></script>
  5.     <script src="/soap/ajax/32.0/apex.js" type="text/javascript"></script>
  6.     <script type="text/javascript">
  7.         function showMessage(){
  8.  
  9.             var aId = "{!AdlId}";
  10.             alert(aId);
  11.                 
  12.             var sobjects = sforce.connection.retrieve("Id,Name", "AddtionalLabels__c", ['a0UN0000006se4qMAA']);
  13.             for (var i=0; i < sobjects.length; i++) {
  14.                 alert(sobjects[i].Id);
  15.             }
  16.         }
  17.     </script>
  18.         
  19.     <apex:form target="_blank">
  20.  
  21.         <apex:panelGrid columns="4" columnClasses="col" styleClass="grd" onclick="showMessage();">
  22.             <apex:outputText value="1A" styleClass="cell"/>
  23.             <apex:outputText value="2A" styleClass="cell"/>
  24.             <apex:outputText value="3A" styleClass="cell"/>
  25.             <apex:outputText value="4A" styleClass="cell"/>
  26.         </apex:panelGrid>
  27.  
  28.     </apex:form>    
  29.  
  30. </apex:page>
----------------------------------------------------------------------------------------------
i have two name fields name1 and name 2
If name one of any part in name 2 then a check box should be checked...
Example 
name 1 =HiTech city
Name2 = Hyd city
City is commom word in both
 So check box checked automatically
i am inserting Standard price book entry as well as Custom Price book entry for new Products (identified by Futurecodeset which contains productcodes for new Product)in my Batch apex  to call Method 1)insertSTDPBEntry(futurePCodeSet);and 2)insertCUSTOMPBEntry(futurePCodeSet);
//batch class
global class ProductBatchInsert implements Database.batchable<sobject>{
    global Map<String, Product2> pCodeToPMap = new Map<String, Product2>();
    global Map<String, Product2> existingProductCodeMap = new Map<String, Product2>(); // existing products from product codes uploaded by  file
    global List<Product2> newPList; // product list from csv for update (New)
    global List<Product2> oldPList; // product list from salesforce for update (Old)
    global List<Product2> insertPList; // product list to insert
    global List<Product2> insertPcloudList;//clouds products to be inserted
    global Set<String> futurePCodeSet; 
    global static Decimal exchangeRateUSDTOEUR = 0.0;
    global static Decimal exchangeRateUSDTOGBP = 0.0;
    global static Decimal exchangeRateUSDTOAED = 0.0;
    
    
    
    
    global ProductBatchInsert(){}
    
    global Database.QueryLocator start(Database.BatchableContext BC) {
        // collect the batches of records or objects to be passed to execute
         
        String query = 'SELECT ID,Item_Category_ID__c,Contract_Price__c,DiscountCategory__c,Brand__c,Item_Category_Name__c,Manufacturer_Part_Number__c,Manufacturer__c,MSRP__c,Name,Part_Description__c,Sender_ID__c,Technology__c,Vendor_Part_Number__c FROM Oracle201815__c';
        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext batchableContext, List<Oracle201815__c> scope){ 
        Product2 p2Obj = new Product2();
        for(Oracle201815__c ProductFileIndividualRec : scope){
            if(ProductFileIndividualRec.Manufacturer_Part_Number__c!=null){
            	List<String> customFieldset = new List<String>();
                p2Obj = new Product2();
                p2Obj.isActive = true; 
                p2Obj.ProductCode = ProductFileIndividualRec.Manufacturer_Part_Number__c;
                p2Obj.Name = ProductFileIndividualRec.Part_Description__c;
                p2Obj.Category__c=ProductFileIndividualRec.Item_Category_Name__c;               
                p2Obj.Description=ProductFileIndividualRec.Part_Description__c;               
                p2Obj.List_Price__c=ProductFileIndividualRec.MSRP__c;               
                p2Obj.Product_Manufacturer__c=ProductFileIndividualRec.Manufacturer__c;
              
               	customFieldset = CintraUtil.DecideCustomFields(ProductFileIndividualRec.Part_Description__c,ProductFileIndividualRec.Item_Category_Name__c);//method to determine the cintra category and Revenue type and skip the cloud realted products
                    if(customFieldset!=null && customFieldset.size()>0){
                    	 System.debug('customFieldsetnotnull'+customFieldset); 
                        p2Obj.Cintra_Category__c=customFieldset.get(1);
                        System.debug('CintraCategoryDecisionResult'+customFieldset.get(1));
                        p2Obj.Family=customFieldset.get(0);
                        System.debug('CintrafamilyDecisionResult'+customFieldset.get(0));
                        p2Obj.Product_Family_Group__c = 'Resell';
                     }
                     else{
                     	 System.debug('customFieldsetnull');
                     	p2Obj.Cintra_Category__c='NA';
                        p2Obj.Family='NA';
                        p2Obj.Product_Family_Group__c='NA';
                     }
                //System.debug('customFieldsetvalues'+customFieldset);
                pCodeToPMap.put(ProductFileIndividualRec.Manufacturer_Part_Number__c,p2Obj);
                
                
    			}
				}
        
        System.debug('pCodeToPMaplist'+pCodeToPMap.size());
        if(pCodeToPMap != null && pCodeToPMap.size() > 0){
            System.debug('before insertingexistingproductmap00001'+pCodeToPMap.keyset());
            //List<String> pCodeSet =new List<String>(pCodeToPMap.keyset());
            //System.debug('listofproductcodes***'+pCodeSet);
            /*for(String st : pCodeToPMap.keyset() ){
               pCodeSet.add('\'+st+'"') ;
            }*/
         for(PricebookEntry  pricebookEntryObj : [SELECT Product2Id,Product2.ChangeLog__c,Product2.IsActive,Product2.ProductCode,Product2.Name,Product2.Category__c,Product2.Description,Product2.List_Price__c,Product2.Product_Manufacturer__c,Product2.Revenue_Type__c,Product2.Artesian_Comment__c,Product2.Cintra_Category__c,Product2.Family,Product2.Product_Family_Group__c FROM PricebookEntry WHERE ((Product2.ProductCode IN : pCodeToPMap.keyset()) and (CurrencyIsoCode ='USD') and (Pricebook2.name = 'Cintra Master Pricebook 2017 - 2018'))]){
               System.debug('before insertingexistingproductmap0000');
             if(pricebookEntryObj.Product2.ProductCode != null){
                    System.debug('before insertingexistingproductmap0');
                    Product2 pObj1 = new product2();
                        pObj1.Id=pricebookEntryObj.Product2Id;
                           pObj1.IsActive=pricebookEntryObj.Product2.IsActive; 
                           pObj1.ProductCode=pricebookEntryObj.Product2.ProductCode;
                           pObj1.Name=pricebookEntryObj.Product2.Name;
                           pObj1.Category__c=pricebookEntryObj.Product2.Category__c;
                           pObj1.Description=pricebookEntryObj.Product2.Description;
                           pObj1.List_Price__c=pricebookEntryObj.Product2.List_Price__c;
                           pObj1.Product_Manufacturer__c=pricebookEntryObj.Product2.Product_Manufacturer__c;
                 		   pObj1.ChangeLog__c=pricebookEntryObj.Product2.ChangeLog__c;
                          // pObj1.Revenue_Type__c=pricebookEntryObj.Product2.Revenue_Type__c;
                           pObj1.Artesian_Comment__c=pricebookEntryObj.Product2.Artesian_Comment__c;
                           pObj1.Cintra_Category__c=pricebookEntryObj.Product2.Cintra_Category__c;
                           pObj1.Family=pricebookEntryObj.Product2.Family;
                           pObj1.Product_Family_Group__c =pricebookEntryObj.Product2.Product_Family_Group__c;
             		System.debug('before insertingexistingproductmap1');
                    existingProductCodeMap.put(pricebookEntryObj.Product2.ProductCode, pObj1);
                    System.debug('before insertingexistingproductmap2');
                    System.debug('existingProductCodeMap'+existingProductCodeMap.values());
               	 }    
            }
            newPList = new List<Product2>();
            oldPList = new List<Product2>();
            insertPList = new List<Product2>();//contains new Product List for insert
            insertPcloudList = new List<Product2>();//contains new cloudProduct List for insert
            futurePCodeSet = new Set<String>();
            
           for(String Pcode : pCodeToPMap.keySet()){
               System.debug('pCodeToPMapsizecheck'+pCodeToPMap.size());
                if(existingProductCodeMap.keySet().contains(PCode)){
                    oldPList.add(existingProductCodeMap.get(PCode));
                    newPList.add(pCodeToPMap.get(PCode));
                    //System.debug('newProductList'+newPList);
                     System.debug('oldPList****'+oldPList);
                     System.debug('newPList******'+newPList);
                    
                }else{
                    if(pCodeToPMap.get(PCode).Family!='NA'){//excluding products whose product family is NA means non cloud products
                    insertPList.add(pCodeToPMap.get(PCode));
                    System.debug('insertproductlist****()'+insertPList);
                     futurePCodeSet.add(PCode);
                      System.debug('futurePCodeSet****()'+futurePCodeSet);
                    }//product codes to create StdPBEntry and CustomPBEntry
                    else{
                    	insertPcloudList.add(pCodeToPMap.get(PCode));
                    	//System.debug('cloudlistsize****'+insertPcloudList.size());
                    }
                    
                }
                
                
            }for(Product2 pcloud:insertPcloudList){
            	System.debug('cloudlistsize****'+pcloud.ProductCode);
            }
            //System.debug('cloudlistsize****'+insertPcloudList);
            System.debug('new products in file******'+insertPList);
            
            if(insertPList != null && insertPList.size() > 0){
                System.debug('insertplistsize****'+insertPList.size());
                insert insertPList;
                insertPList.clear();
                insertSTDPBEntry(futurePCodeSet);
                insertCUSTOMPBEntry(futurePCodeSet);
                
            }
            if(oldPList != null && oldPList.size() > 0){
                System.debug('productswithchangesize****'+oldPList.size());
                System.debug('productswithchange****'+oldPList);
                compareAndUpdateProducts();
            }
   	 	}
    }
    
           

        
    
    global void finish(Database.BatchableContext BC){
            // Add batch job calling logic in Finish method
		   // ProductInactivationBatchClass b = new ProductInactivationBatchClass(); 
			//database.executebatch(b);
  }
     public static void insertSTDPBEntry(Set<String> futurePCodeSet){
        String pricebookId = null;
        if(futurePCodeSet!= null && futurePCodeSet.size()>0){
            List<Pricebook2> pbList = [select Id, Name, IsActive from PriceBook2 where IsStandard=True LIMIT 1]; 
            if(pbList != null && pbList.size()>0){
                pricebookId = pbList[0].Id;
            }
            if(pricebookId != null){
                PricebookEntry pbeObj;
                List<PricebookEntry> pbeList = new List<PricebookEntry>();
                exchangeRateUSDTOEUR = 0.0;
                  exchangeRateUSDTOGBP = 0.0;
                  exchangeRateUSDTOAED = 0.0;
                
                try{
                    CintraOtherSettingsCS__c cosObj = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_EUR');
                    exchangeRateUSDTOEUR = Decimal.valueOf(cosObj.value__c);
                    System.debug('exchangeRateUSDTOEUR***'+exchangeRateUSDTOEUR);
                    CintraOtherSettingsCS__c cosObj1 = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_GBP');
                    exchangeRateUSDTOGBP = Decimal.valueOf(cosObj1.value__c);
                    System.debug('exchangeRateUSDTOGBP***'+exchangeRateUSDTOGBP);
                    CintraOtherSettingsCS__c cosObj2 = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_AED');
                    exchangeRateUSDTOAED = Decimal.valueOf(cosObj2.value__c);
                }catch(Exception e){
                  exchangeRateUSDTOEUR = 0.8;
                  exchangeRateUSDTOGBP = 0.8;
                  exchangeRateUSDTOAED = 0.8;
                }
                for(Product2 pObj : [SELECT Id, ProductCode, List_Price__c, CurrencyIsoCode FROM Product2 WHERE ProductCode IN : futurePCodeSet]){
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = pObj.CurrencyIsoCode;
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? pObj.List_Price__c : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                    
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = 'GBP';
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? (pObj.List_Price__c * exchangeRateUSDTOGBP) : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                    
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = 'EUR';
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? (pObj.List_Price__c * exchangeRateUSDTOEUR) : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                    
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = 'AED';
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? (pObj.List_Price__c * exchangeRateUSDTOAED) : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                }
                if(pbeList != null && pbeList.size() > 0){
                    insert pbeList;
                }
            }
        }
    }
    
    public static void insertCUSTOMPBEntry(Set<String> futurePCodeSet){
        String pricebookId = null;
        //pricebookId = Label.Active_Pricebook;//create one custom label which contains the id for Custom Pricebook
        if(futurePCodeSet!= null && futurePCodeSet.size()>0){
            List<Pricebook2> pbList = [select Id, Name, IsActive from PriceBook2 where NAME ='Cintra Master Pricebook 2017 - 2018']; 
            if(pbList != null && pbList.size()>0){
                pricebookId = pbList[0].Id;
            }
            if(pricebookId != null){
                PricebookEntry pbeObj;
                List<PricebookEntry> pbeList = new List<PricebookEntry>();
                exchangeRateUSDTOEUR = 0.0;
                  exchangeRateUSDTOGBP = 0.0;
                  exchangeRateUSDTOAED = 0.0;
                
                try{
                    CintraOtherSettingsCS__c cosObj = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_EUR');
                    exchangeRateUSDTOEUR = Decimal.valueOf(cosObj.value__c);
                    system.debug('checkingcustomsettingvalues1'+exchangeRateUSDTOEUR);
                    CintraOtherSettingsCS__c cosObj1 = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_GBP');
                    exchangeRateUSDTOGBP = Decimal.valueOf(cosObj1.value__c);
                    system.debug('checkingcustomsettingvalues2'+exchangeRateUSDTOGBP);
                    CintraOtherSettingsCS__c cosObj2 = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_AED');
                    exchangeRateUSDTOAED = Decimal.valueOf(cosObj2.value__c);
                }catch(Exception e){
                  
                 	 exchangeRateUSDTOGBP = 0.8;
                     exchangeRateUSDTOEUR = 0.8;
                  	exchangeRateUSDTOAED = 0.8;
                }
                for(Product2 pObj : [SELECT Id, ProductCode, List_Price__c, CurrencyIsoCode FROM Product2 WHERE ProductCode IN : futurePCodeSet]){
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = pObj.CurrencyIsoCode;
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? pObj.List_Price__c : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                    
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = 'GBP';
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? (pObj.List_Price__c * exchangeRateUSDTOGBP) : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                    
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = 'EUR';
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? (pObj.List_Price__c * exchangeRateUSDTOEUR) : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                    
                    pbeObj = new PriceBookEntry();
                    pbeObj.Product2ID = pObj.Id;
                    pbeObj.PriceBook2ID = pricebookId;
                    pbeObj.CurrencyIsoCode = 'AED';
                    pbeObj.UnitPrice = (pObj.List_Price__c != null) ? (pObj.List_Price__c * exchangeRateUSDTOAED) : 0.0;
                    pbeObj.IsActive = true;
                    pbeList.add(pbeObj);
                }
                if(pbeList != null && pbeList.size() > 0){
                    insert pbeList;
                }
            }
        }
    }
      private void compareAndUpdateProducts(){
        exchangeRateUSDTOEUR = 0.0;
        exchangeRateUSDTOGBP = 0.0;
        exchangeRateUSDTOAED = 0.0;
        try{
            /*if(test.isRunningTest()){
                exchangeRateUSDTOGBP = 0.8;
                exchangeRateUSDTOEUR = 0.8;
                exchangeRateUSDTOAED = 0.8;}*/
        	CintraOtherSettingsCS__c cosObj = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_EUR');
            exchangeRateUSDTOEUR = Decimal.valueOf(cosObj.value__c);
            system.debug('checkingcustomsettingvalues1'+exchangeRateUSDTOEUR);
            CintraOtherSettingsCS__c cosObj1 = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_GBP');
            exchangeRateUSDTOGBP = Decimal.valueOf(cosObj1.value__c);
            system.debug('checkingcustomsettingvalues2'+exchangeRateUSDTOGBP);
            CintraOtherSettingsCS__c cosObj2 = CintraOtherSettingsCS__c.getValues('Oracle_Exchange_Rate_USD_TO_AED');
            exchangeRateUSDTOAED = Decimal.valueOf(cosObj2.value__c);
             
        }
        catch(Exception e){
     	 exchangeRateUSDTOGBP = 0.8;
         exchangeRateUSDTOEUR = 0.8;
      	exchangeRateUSDTOAED = 0.8;
        }
        List<Product2> updatePList = new List<Product2>();
        Map<Id, Decimal> pIdToPriceMap = new Map<Id, Decimal>();
        List<PricebookEntry> pCodeToPMap = new List<PricebookEntry>();
        Boolean isUpdate;
        Boolean isPricebookUpdate;
         
        for(Integer i=0; i<oldPList.size(); i++){
            isUpdate = false;
            isPricebookUpdate = false;
            String Changelog=(oldPList[i].ChangeLog__c!=null)?oldPList[i].ChangeLog__c:'';
           
            if(newPList[i].isActive != oldPList[i].isActive){
                Changelog+='Product'+oldPList[i].ProductCode+'changed from'+oldPList[i].isActive+'to'+newPList[i].isActive+'\r\n';
                oldPList[i].isActive = newPList[i].isActive;
                isUpdate = true;
                
            }
            if(newPList[i].Name != null && newPList[i].Name != oldPList[i].Name){
                Changelog+='Product'+oldPList[i].ProductCode+'Name changed from'+oldPList[i].Name+'to'+newPList[i].Name+'\r\n';
                oldPList[i].Name = newPList[i].Name;
                isUpdate = true;
                
            }
            if(newPList[i].List_Price__c != null && newPList[i].List_Price__c != oldPList[i].List_Price__c){
                Changelog+='Product'+oldPList[i].ProductCode+'List price changed from'+oldPList[i].List_Price__c+'to'+newPList[i].List_Price__c+'\r\n';
                oldPList[i].List_Price__c = newPList[i].List_Price__c;
                isUpdate = true;
                isPricebookUpdate = true;
            }
            if(newPList[i].Family != null && newPList[i].Family != oldPList[i].Family){
                 Changelog+='Product'+oldPList[i].ProductCode+'Family changed from'+oldPList[i].Family+'to'+newPList[i].Family+'\r\n';
                oldPList[i].Family = newPList[i].Family;
                isUpdate = true;
            }
            if(newPList[i].Description != null && newPList[i].Description != oldPList[i].Description){
                 Changelog+='Product'+oldPList[i].ProductCode+'Description changed from'+oldPList[i].Description+'to'+newPList[i].Description+'\r\n';
                oldPList[i].Description = newPList[i].Description;
                isUpdate = true;
            }
           if(newPList[i].Category__c !=null && newPList[i].Category__c != oldPList[i].Category__c ) {
               if( !(newPList[i].Category__c).containsIgnoreCase('cloud')){
                    Changelog+='Product'+oldPList[i].ProductCode+'Category changed from'+oldPList[i].Category__c+'to'+newPList[i].Category__c+'\r\n';
                oldPList[i].Category__c = newPList[i].Category__c;
                oldPList[i].Cintra_Category__c=newPList[i].Cintra_Category__c;
               oldPList[i].Family=newPList[i].Family;
                isUpdate = true;
                   }
            }
            if(isUpdate){
                //Changelog+='on'+System.now();
                oldPlist[i].ChangeLog__c='['+System.now()+']'+'--'+Changelog;
                updatePList.add(oldPList[i]);
                System.debug('updatePlist***'+updatePList);
            }
            if(isPricebookUpdate){
                pIdToPriceMap.put(oldPList[i].Id, newPList[i].List_Price__c);
            }
        }
        if(updatePList != null && updatePList.size() > 0){
            update updatePList;
        }
        List<PricebookEntry> updatePBEList = new List<PricebookEntry>();
        for(PricebookEntry pbeObj : [SELECT Id, UnitPrice, CurrencyIsoCode, Product2Id FROM PricebookEntry WHERE Product2Id IN : pIdToPriceMap.keySet()]){
            if(pbeObj.CurrencyIsoCode == 'USD'){
                pbeObj.UnitPrice = pIdToPriceMap.get(pbeObj.Product2Id);
            }else if(pbeObj.CurrencyIsoCode == 'GBP'){
                pbeObj.UnitPrice = pIdToPriceMap.get(pbeObj.Product2Id) * exchangeRateUSDTOGBP;
            }else if(pbeObj.CurrencyIsoCode == 'AED'){
                pbeObj.UnitPrice = pIdToPriceMap.get(pbeObj.Product2Id) * exchangeRateUSDTOAED;
            }else if(pbeObj.CurrencyIsoCode == 'EUR'){
                pbeObj.UnitPrice = pIdToPriceMap.get(pbeObj.Product2Id) * exchangeRateUSDTOEUR;
            }
            updatePBEList.add(pbeObj);
        }
        if(updatePBEList != null && updatePBEList.size() > 0){
            update updatePBEList;
        }
    }
    
   
  
    
    
}
//test class for Batch class
@isTest
public class ProductBatchInserttest 
{
   @isTest(seeAllData=false)
    static  void testMethod1() 
    {
        List<Oracle201815__c> lstOraclefile= new List<Oracle201815__c>();
       // List<Product2> prdObj = new List<Product2>();
      /*  List<PricebookEntry> pbeList = new List<PricebookEntry>();
       CintraOtherSettingsCS__c cosObj = new CintraOtherSettingsCS__c(Name='Oracle_Exchange_Rate_USD_TO_EUR', Value__c = '1');
      insert cosObj;
        CintraOtherSettingsCS__c cosObj1 = new CintraOtherSettingsCS__c(Name='Oracle_Exchange_Rate_USD_TO_GBP', Value__c = '0.8');
      insert cosObj1;
        CintraOtherSettingsCS__c cosObj2 = new CintraOtherSettingsCS__c(Name='Oracle_Exchange_Rate_USD_TO_AED', Value__c = '0.6');
      insert cosObj2;*/
      
        Product2 pObj = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1',productCode = 'Name10', isActive = true);
       insert(pObj);
        //standard PBEntry
       Id pricebookId = Test.getStandardPricebookId(); 
        PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = pObj.Id,CurrencyIsoCode = 'USD',
            UnitPrice = 10000, IsActive = true);
        insert standardPrice;
        PricebookEntry standardPrice1 = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = pObj.Id,CurrencyIsoCode = 'GBP',
            UnitPrice = 10000, IsActive = true);
        insert standardPrice1;
        PricebookEntry standardPrice2 = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = pObj.Id,CurrencyIsoCode = 'AED',
            UnitPrice = 10000, IsActive = true);
        insert standardPrice2;
        PricebookEntry standardPrice3 = new PricebookEntry(
            Pricebook2Id = pricebookId, Product2Id = pObj.Id,CurrencyIsoCode = 'EUR',
            UnitPrice = 10000, IsActive = true);
        insert standardPrice3;
   
      
        //CustomPBentry
        Pricebook2 customPB = new Pricebook2(Name='Cintra Master Pricebook 2017 - 2018', isActive=true);
        insert customPB;
        
        // 2. Insert a price book entry with a custom price.
       	 PricebookEntry customPBEUSD = new PricebookEntry(Pricebook2Id = customPB.Id, Product2Id = pObj.Id,UnitPrice = 12000,CurrencyIsoCode = 'USD', IsActive = true);
        insert customPBEUSD;
        PricebookEntry customPBEGBP = new PricebookEntry(Pricebook2Id = customPB.Id, Product2Id = pObj.Id,UnitPrice = 12000,CurrencyIsoCode = 'GBP', IsActive = true);
        insert customPBEGBP;
        PricebookEntry customPBEEUR = new PricebookEntry(Pricebook2Id = customPB.Id, Product2Id = pObj.Id,UnitPrice = 12000,CurrencyIsoCode = 'EUR', IsActive = true);
        insert customPBEEUR;
        PricebookEntry customPBEAED = new PricebookEntry(Pricebook2Id = customPB.Id, Product2Id = pObj.Id,UnitPrice = 12000,CurrencyIsoCode = 'AED', IsActive = true);
        insert customPBEAED;
        
        
        
        
        
        for(Integer i=0 ;i <100;i++)//for non cloud Products
        {
            Oracle201815__c oracleRec = new Oracle201815__c();
           
              	oracleRec.Manufacturer_Part_Number__c='CODE'+i;
                oracleRec.Part_Description__c='Name'+i;
                oracleRec.Item_Category_Name__c='HW'+i;               
                oracleRec.Part_Description__c='Name'+i;               
             	oracleRec.MSRP__c=i;              
                oracleRec.Manufacturer__c='oracle';
            lstOraclefile.add(oracleRec);
        }
        for(Integer i=0 ;i <100;i++)//for cloud products
        {
            Oracle201815__c oracleRec = new Oracle201815__c();
           
              oracleRec.Manufacturer_Part_Number__c='Name1'+i;
                oracleRec.Part_Description__c='Name1'+i;
                oracleRec.Item_Category_Name__c='Cloud'+i;               
                oracleRec.Part_Description__c='Name1'+i;               
              oracleRec.MSRP__c=i;              
                oracleRec.Manufacturer__c='oracle';
            lstOraclefile.add(oracleRec);
        }
        Oracle201815__c oracleRec = new Oracle201815__c();
           
              	oracleRec.Manufacturer_Part_Number__c = 'PROD1000';
                oracleRec.Part_Description__c='Name1';
                oracleRec.Item_Category_Name__c='SW';               
                oracleRec.Part_Description__c='Name1';               
              	oracleRec.MSRP__c=100;              
                oracleRec.Manufacturer__c='oracle';
        		
        
            lstOraclefile.add(oracleRec);
        
        insert lstOraclefile;
        
        Test.startTest();

            ProductBatchInsert obj = new ProductBatchInsert();
           ID BatchId =DataBase.executeBatch(obj,2000); 
        //System.abortJob(batchID);
            
        Test.stopTest();
    }
}

 
I have a group that I am on boarding to our SF instance.  They mainly have Contact data that contains primarily 5 fields of important contact data which includes Level, Discpline, Sector, Speciality and Sub Specialty.  They use these 5 fields to set filters to run reports for email campaigns and physical samples they need to send out.  The main issue is that these fields in their system are multi-select.  I don't want to create 5 multi select fields for them because reporting would be diffficult.  Any ideas on how to get this working with the least amount of fields and avoiding multi-select?
Hello Everyone, Hope all are doing good i have some information for you all go through it and give me a reply for that!

Amazon EC2 (AWS Certified)is an Infrastructure as a Service which offers pay-by-hour servers (EC2), storage (S3) etc. You bring your own software to the table – OS (Red Hat, Windows, whatever), Database (MySQL, Oracle, DB2, whatever), Search (your pick), Business Intelligence (Cognos, Oracle BI, whatever) – and then you piece it together and get it all to work. The benefits are that you can do whatever you want – and the con is you have to manage complexity yourself.

Force.com, by contrast, is a Platform as a Service that provides a pre-integrated offering that already has a database, search, BI Reports, identity/security etc. all built in – that you program using a Java-like language (Apex). With the newly announced VMforce, a VMware and Salesforce.com offering, you will be able to use Java soon. Force.com automatically backs up your data, manages upgrades (your apps don’t need to know if Force.com is running on database version 11i or 11g, Dell boxes or Sun boxes, Linux or Windows etc.)

Regards
Sarahjohn
{!REQUIRESCRIPT("/xdomain/xdomain.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
{!REQUIRESCRIPT("/support/console/39.0/integration.js")}

var Program='{!Program_Member_MVN__c.Program_Name__c}';
var Pname=sforce.connection.query("Select Program__c from Program_Names__c");
var rec16 = Pname.getArray('records');
var status='{!Program_Member_MVN__c.Status_MVN__c}';
var PmId='{!JSENCODE(Program_Member_MVN__c.Id)}'; 
var PName='{!Program_Member_MVN__c.Program_Name__c}'; 
var url;
if (sforce.console.isInConsole()) {
if(Program == rec16){
alert("You are on the wrong Program")
} 

else if(status == 'On Therapy')
{
url = "/apex/Milestone_skip?id="+PmId;
window.open(url,'_blank','toolbar=0,location=0,menubar=0,width=800,scrollbars'); 
}  
else
{
alert("Patient must be ‘On-Therapy’ before skipping to a milestone");
}
}

This is my java script on click button code.In this i am querying  custom setting here:var Pname=sforce.connection.query("Select Program__c from Program_Names__c");
And i want to compare to field to show a alert.So i have to multiple values in custom setting.So how can i access all the values given in the custom setting in the java script code?