• Rahul Sangwan7341
  • NEWBIE
  • 334 Points
  • Member since 2014

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 88
    Replies
Hi,
I want to write a test class for my visualforce controller hear is the code of my visualforce page and controller



-----------------------visualforce page--------------------------------------
<apex:page showHeader="false" controller="insertController1">
  <apex:form id="formId">
   <apex:PageBlock >
     <apex:pageBlockSection >
     
     <apex:inputField value="{!prpty.Name}"/>
     <apex:inputField value="{!prpty.Address__c}"/>
     
    
     </apex:pageBlockSection>     
       <apex:commandButton value="Save" action="{!addNewprpty}"/>
   </apex:PageBlock>
  </apex:form>
</apex:page>

------------------------------ Controller---------------------

public class insertController1 {

    public Property_Name__c prpty { get; set; }

    // Here initialize the prpty object
    public insertController1() {
        prpty = new Property_Name__c();
    }

    public PageReference addNewprpty() {
        insert prpty;
        
                pagereference ref = new pagereference('/apex/tenant');
        return ref;
    }
}

Any help would appreciable
if u want delete my custom object record (estimate) send notofication to all profiles
Hey,

I had a question and I was hoping that someone could help me with it. I am trying to develop a custom a visualforce page and design the elements I am using in it such as, Charts, Tabs, etc. In my code, I am using a javascript which is hosted here : http://d3js.org/d3.v3.min.js

and using it in my code like this :
<apex:includeScript value="//d3js.org/d3.v3.min.js"/>

As it is on http and not on https, it's throwing me an error in the background as the attached picture says. Apparently, salesforce doesn't allow us to access scripts on "unsecure connection." 
User-added image

Is there any solution for this ?
Hi,

I have a picklist field called Customer Type in Opportunity page with options, NEW, EXISTING and INACTIVE. I wan to make it required, if Opportunity stage is CLOSED WON.

How can this be achieved ?
hi Guys,

I have a requirement to send an email alert with a PDF FIle attached to that record when a particular codnition is met . Can nayone please help with the Trigger code for this? 
  • February 26, 2015
  • Like
  • 0
User-added image

For the above task i have created a class as below,


public class StringArrayTest 
{
  public string[] arraynames;
  public StringArrayTest()
  {
   arraynames=new string[]{};
  }
  public string[] generateStringArray(integer num)
  {
  
  for(integer i=0;i<num;i++)
  {
   string  s='Test'+i;
   /*arraynames.add(s);*/
   system.debug(s);
  }
  return arraynames; 
  }
}




it showing below error


User-added image


where i did mistake.?
Hello,
I'm modifying the Lead page to include more information, and it's become large. I have to scroll up and down to view all the Lead information.
I have some checkbox and list that refresh my page to show more or less inputs/outputs, and every time I select a new item on the list, or check the checkbox, the page refresh and send me to the top. This is really annoying because I have to scroll down to complete the Lead information every time I change an option from my list. Can someone please help me?
This is part of my VF code:

     <apex:pageBlockSection title="Commercial Information">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Country (Commercial)" />
                    <apex:outputPanel >
                        <apex:inputField value="{!lead.Country_Commercial__c}" >
                            <apex:actionSupport event="onchange"
                                    rerender="LeadForm" status="status" action="{!XXX}" />
                        </apex:inputField>
                        <apex:actionStatus startText="applying value..." id="status" />
                    </apex:outputPanel>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Province (Commercial)" />
                    <apex:inputField value="{!lead.Province_Commercial_2__c}" />
                </apex:pageBlockSectionItem>
     </apex:pageBlockSection>

I tried to put an anchor in the apex:pageBlockSection like id="CommercialInformation" and a javascript function (see below) called at apex:actionSupport on a onComplete attribute, but it doesn't work.
       function focusOnElement(id) {
            $(id).goTo(); // need to 'go to' this element
        }

Any thoughts or suggestions would be greatly appreciated. Thanks.

Adrian
Hi Experts,

Does anyone know of a way to attach files, to an e-mail, from notes and attachments? Instead of downloading the attachement to the hard drive and uploading to the e-mail.

Any help would be greatly appreciated, thank-you.

v/r
Shane Quiring

I want to hide following three elements from dashboard view, how can I achieve it??




User-added image

I have two standard objects, Order and Contact. I have created a Contact lookup (API- Contact_Lookup__c) in Order and included its related  list in the page layout of Contact.

But when I enter a new record in Contact, then go to related list to add an order to it, hit save, the new Order record gets inserted in the Order records but it does not get displayed in the related list on contact detail page for that record.

Please help

{
  "Extract_PricebookEntry": {
    "action": "sfdcDigest",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "maxAllowedOffset": 1500,
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "Product2Id"
        }
      ],
      "concurrentBatches": 12,
      "object": "PricebookEntry"
    }
  },
  "augment_Payment__c_Opportunity_2": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "sfdcDigest_Payment__c_2",
      "left_key": [
        "Opportunity__c"
      ],
      "right_select": [
        "Name",
        "Id",
        "AccountId",
        "OwnerId"
      ],
      "right": "sfdcDigest_Opportunity_2",
      "relationship": "Opportunity__c"
    }
  },
  "augment_Payment__c_Opportunity_0": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "sfdcDigest_Payment__c_0",
      "left_key": [
        "Opportunity__c"
      ],
      "right_select": [
        "Amount",
        "IsClosed",
        "Name",
        "Id",
        "AccountId",
        "OwnerId"
      ],
      "right": "sfdcDigest_Opportunity_0",
      "relationship": "Opportunity__c"
    }
  },
  "sfdcDigest_Payment__c_0": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Donor_Code__c"
        },
        {
          "name": "Name"
        },
        {
          "name": "Payment_Amount__c"
        },
        {
          "name": "Id"
        },
        {
          "name": "Opportunity__c"
        }
      ],
      "object": "Payment__c"
    }
  },
  "sfdcDigest_User": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "IsActive"
        },
        {
          "name": "Name"
        },
        {
          "name": "Id"
        }
      ],
      "object": "User"
    }
  },
  "Join_OpportunityLineItemPricebookEntry": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left_key": [
        "PricebookEntryId"
      ],
      "left": "Extract_OpportunityLineItem",
      "right_select": [
        "Product2Id"
      ],
      "right": "Extract_PricebookEntry",
      "relationship": "Pricebook"
    }
  },
  "Extract_Opportunity": {
    "action": "sfdcDigest",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "maxAllowedOffset": 1500,
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "AccountId"
        },
        {
          "name": "OwnerId"
        },
        {
          "name": "Name"
        },
        {
          "name": "StageName"
        },
        {
          "name": "LeadSource"
        },
        {
          "name": "IsWon"
        },
        {
          "name": "Type"
        },
        {
          "name": "IsClosed"
        },
        {
          "name": "ForecastCategory"
        },
        {
          "name": "ForecastCategoryName"
        },
        {
          "name": "CreatedDate"
        },
        {
          "name": "CloseDate"
        },
        {
          "name": "Amount"
        },
        {
          "name": "CreatedById"
        }
      ],
      "concurrentBatches": 12,
      "object": "Opportunity"
    }
  },
  "Join_AccountOwner": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left_key": [
        "OwnerId"
      ],
      "left": "Extract_Account",
      "right_select": [
        "Name",
        "Username"
      ],
      "right": "Extract_User",
      "relationship": "Owner",
      "operation": "LookupMultiValue"
    }
  },
  "sfdcDigest_Account": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "AccountSource"
        },
        {
          "name": "Type"
        },
        {
          "name": "Id"
        }
      ],
      "object": "Account"
    }
  },
  "augment_User": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "augment_Case_Account",
      "left_key": [
        "OwnerId"
      ],
      "right_select": [
        "IsActive",
        "Name"
      ],
      "right": "sfdcDigest_User",
      "relationship": "OwnerId"
    }
  },
  "Extract_Product": {
    "action": "sfdcDigest",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "maxAllowedOffset": 1500,
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "ProductCode"
        },
        {
          "name": "Name"
        },
        {
          "name": "Family"
        }
      ],
      "concurrentBatches": 12,
      "object": "Product2"
    }
  },
  "sfdcDigest_Payment__c_2": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Donor_Code__c"
        },
        {
          "name": "Payment_Amount__c"
        },
        {
          "name": "Id"
        },
        {
          "name": "Opportunity__c"
        }
      ],
      "object": "Payment__c"
    }
  },
  "Extract_User": {
    "action": "sfdcDigest",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "chunkSize": 1500,
      "maxAllowedOffset": 1500,
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "Username"
        },
        {
          "name": "Name"
        },
        {
          "name": "UserRoleId"
        },
        {
          "name": "ManagerId"
        }
      ],
      "concurrentBatches": 12,
      "object": "User"
    }
  },
  "sfdcDigest_User_1": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "Id"
        }
      ],
      "object": "User"
    }
  },
  "register_Payment with Donor_0": {
    "action": "sfdcRegister",
    "parameters": {
      "name": "Payment with Donor",
      "alias": "Payment_with_Donor",
      "source": "augment_User_0"
    }
  },
  "sfdcDigest_User_2": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "Name"
        }
      ],
      "object": "User"
    }
  },
  "Join_OpportunityOwner": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left_key": [
        "OwnerId"
      ],
      "left": "Join_OpportunityAccount",
      "right_select": [
        "Name",
        "Username"
      ],
      "right": "Extract_User",
      "relationship": "Owner",
      "operation": "LookupMultiValue"
    }
  },
  "sfdcDigest_User_0": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "Id"
        }
      ],
      "object": "User"
    }
  },
  "Join_OpportunityLineItemPricebookEntryProduct": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left_key": [
        "Pricebook.Product2Id"
      ],
      "left": "Join_OpportunityLineItemPricebookEntry",
      "right_select": [
        "ProductCode",
        "Name",
        "Family"
      ],
      "right": "Extract_Product",
      "relationship": "Product"
    }
  },
  "Register_OpportunityProducts": {
    "action": "sfdcRegister",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "rowLevelSecurityFilter": "",
      "name": "Products Opportunities",
      "alias": "products_opportunities",
      "source": "Join_OpportunityOpportunityLineItemPricebookEntryProduct"
    }
  },
  "augment_Account_User_1": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "sfdcDigest_Account_1",
      "left_key": [
        "OwnerId"
      ],
      "right_select": [
        "Name",
        "Id"
      ],
      "right": "sfdcDigest_User_1",
      "relationship": "OwnerId"
    }
  },
  "sfdcDigest_Account_0": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Unique_Id__c"
        },
        {
          "name": "Name"
        },
        {
          "name": "Id"
        }
      ],
      "object": "Account"
    }
  },
  "Join_OpportunityAccount": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left_key": [
        "AccountId"
      ],
      "left": "Extract_Opportunity",
      "right_select": [
        "Name",
        "Type",
        "Industry",
        "BillingCountry",
        "BillingState",
        "AccountSource",
        "OwnerId",
        "Owner.Name"
      ],
      "right": "Join_AccountOwner",
      "relationship": "Account",
      "operation": "LookupMultiValue"
    }
  },
  "sfdcDigest_Account_2": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "Unique_Id__c"
        },
        {
          "name": "Id"
        }
      ],
      "object": "Account"
    }
  },
  "sfdcDigest_Account_1": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "Unique_Id__c"
        },
        {
          "name": "OwnerId"
        }
      ],
      "object": "Account"
    }
  },
  "register_Donor Data_1": {
    "action": "sfdcRegister",
    "parameters": {
      "name": "Donor Data",
      "alias": "Donor_Data",
      "source": "augment_Account_User_1"
    }
  },
  "augment_Account_2": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "augment_Payment__c_Opportunity_2",
      "left_key": [
        "Opportunity__c.AccountId"
      ],
      "right_select": [
        "Name",
        "Unique_Id__c",
        "Id"
      ],
      "right": "sfdcDigest_Account_2",
      "relationship": "Opportunity__c.AccountId"
    }
  },
  "augment_Account_0": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "augment_Payment__c_Opportunity_0",
      "left_key": [
        "Opportunity__c.AccountId"
      ],
      "right_select": [
        "Unique_Id__c",
        "Name"
      ],
      "right": "sfdcDigest_Account_0",
      "relationship": "Opportunity__c.AccountId"
    }
  },
  "augment_User_2": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "augment_Account_2",
      "left_key": [
        "Opportunity__c.OwnerId"
      ],
      "right_select": [
        "Id",
        "Name"
      ],
      "right": "sfdcDigest_User_2",
      "relationship": "Opportunity__c.OwnerId"
    }
  },
  "augment_Case_Account": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "sfdcDigest_Case",
      "left_key": [
        "AccountId"
      ],
      "right_select": [
        "Name",
        "AccountSource",
        "Type"
      ],
      "right": "sfdcDigest_Account",
      "relationship": "AccountId"
    }
  },
  "augment_User_0": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left": "augment_Account_0",
      "left_key": [
        "Opportunity__c.OwnerId"
      ],
      "right_select": [
        "Name",
        "Id"
      ],
      "right": "sfdcDigest_User_0",
      "relationship": "Opportunity__c.OwnerId"
    }
  },
  "Extract_Account": {
    "action": "sfdcDigest",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "Name"
        },
        {
          "name": "OwnerId"
        },
        {
          "name": "AccountSource"
        },
        {
          "name": "Type"
        },
        {
          "name": "Industry"
        },
        {
          "name": "BillingCountry"
        },
        {
          "name": "BillingState"
        },
        {
          "name": "CreatedDate"
        },
        {
          "name": "LastModifiedDate"
        }
      ],
      "object": "Account"
    }
  },
  "Extract_OpportunityLineItem": {
    "action": "sfdcDigest",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "maxAllowedOffset": 1500,
      "fields": [
        {
          "name": "OpportunityId"
        },
        {
          "name": "ProductCode"
        },
        {
          "name": "ListPrice"
        },
        {
          "name": "Quantity"
        },
        {
          "name": "TotalPrice"
        },
        {
          "name": "PricebookEntryId"
        }
      ],
      "concurrentBatches": 12,
      "object": "OpportunityLineItem"
    }
  },
  "Join_OpportunityOpportunityLineItemPricebookEntryProduct": {
    "action": "augment",
    "parameters": {
      "right_key": [
        "Id"
      ],
      "left_key": [
        "OpportunityId"
      ],
      "left": "Join_OpportunityLineItemPricebookEntryProduct",
      "right_select": [
        "Name",
        "StageName",
        "CloseDate",
        "IsWon",
        "Type",
        "IsClosed",
        "LeadSource",
        "ForecastCategory",
        "ForecastCategoryName",
        "CreatedDate",
        "AccountId",
        "Account.Name",
        "Account.OwnerId",
        "Account.Type",
        "Account.Industry",
        "Account.BillingCountry",
        "Account.BillingState",
        "Account.AccountSource",
        "Account.Owner.Name",
        "OwnerId",
        "Owner.Name"
      ],
      "right": "Join_OpportunityOwner",
      "relationship": "Opportunity"
    }
  },
  "sfdcDigest_Case": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Id"
        },
        {
          "name": "CaseNumber"
        },
        {
          "name": "Origin"
        },
        {
          "name": "Reason"
        },
        {
          "name": "Type"
        },
        {
          "name": "AccountId"
        },
        {
          "name": "OwnerId"
        }
      ],
      "object": "Case"
    }
  },
  "sfdcDigest_Opportunity_2": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Name"
        },
        {
          "name": "Id"
        },
        {
          "name": "AccountId"
        },
        {
          "name": "OwnerId"
        }
      ],
      "object": "Opportunity"
    }
  },
  "register_Salesforce Payments_2": {
    "action": "sfdcRegister",
    "parameters": {
      "name": "Salesforce Payments",
      "alias": "Salesforce_Payments",
      "source": "augment_User_2"
    }
  },
  "register_Cases with Accounts": {
    "action": "sfdcRegister",
    "parameters": {
      "name": "Cases with Accounts",
      "alias": "Cases_with_Accounts",
      "source": "augment_User"
    }
  },
  "sfdcDigest_Opportunity_0": {
    "action": "sfdcDigest",
    "parameters": {
      "fields": [
        {
          "name": "Amount"
        },
        {
          "name": "IsClosed"
        },
        {
          "name": "Name"
        },
        {
          "name": "Id"
        },
        {
          "name": "AccountId"
        },
        {
          "name": "OwnerId"
        }
      ],
      "object": "Opportunity"
    }
  },
  "Register_Opportunity": {
    "action": "sfdcRegister",
    "parameters": {
      "SFDCtoken": "SFDCtoken",
      "rowLevelSecurityFilter": "",
      "name": "Opportunities",
      "alias": "opportunities",
      "source": "Join_OpportunityOwner"
    }
  },
  "New_Payment_Ext": {
    "action": "edgemart",
    "parameters": {
      "alias": "New_Payment_CSV"
    }
  },
  "New_Payment_SF": {
    "action": "edgemart",
    "parameters": {
      "alias": "Salesforce_Payments"
    }
  },
  "Append_Payments_All": {
    "action": "append",
    "parameters": {
      "sources": [
        "New_Payment_Ext",
        "New_Payment_SF"
      ]
    }
  }
}
 
Failed
Something went wrong while executing the Append_Payments_All node: Field [Payment_Amount] is missing in 1 out of 2 inputs Field [Opportunity__c.AccountId.Name] is missing in 1 out of 2 inputs Field [Opportunity__c.OwnerId.Name] is missing in 1 out of 2 inputs Field [Donor_Code__c] is missing in 1 out of 2 inputs Field [Opportunity_c_AccountId_Name] is missing in 1 out of 2 inputs Field [Opportunity_c_OwnerId] is missing in 1 out of 2 inputs Field [Opportunity__c.OwnerId] is missing in 1 out of 2 inputs Field [Opportunity_c_IsClosed] is missing in 1 out of 2 inputs Field [Opportunity_c_OwnerId_Name] is missing in 1 out of 2 inputs Field [Opportunity__c] is missing in 1 out of 2 inputs Field [Name] is missing in 1 out of 2 inputs Field [Opportunity__c.Id] is missing in 1 out of 2 inputs Field [Opportunity_c_Name] is missing in 1 out of 2 inputs Field [Opportunity_c_OwnerId_Id] is missing in 1 out of 2 inputs Field [Donor_Code] is missing in 1 out of 2 inputs Field [Opportunity__c.AccountId.Unique_Id__c] is missing in 1 out of 2 inputs Field [Opportunity_c_Amount] is missing in 1 out of 2 inputs Field [Opportunity_c_AccountId] is missing in 1 out of 2 inputs Field [Payment_Amount__c] is missing in 1 out of 2 inputs Field [Id] is missing in 1 out of 2 inputs Field [Opportunity] is missing in 1 out of 2 inputs Field [Payment_Name] is missing in 1 out of 2 inputs Field [Opportunity__c.Name] is missing in 1 out of 2 inputs Field [Opportunity__c.Amount] is missing in 1 out of 2 inputs Field [Opportunity__c.OwnerId.Id] is missing in 1 out of 2 inputs Field [Opportunity__c.IsClosed] is missing in 1 out of 2 inputs Field [Opportunity_c_AccountId_Unique_Id__c] is missing in 1 out of 2 inputs Field [Record_ID] is missing in 1 out of 2 inputs Field [Opportunity_c_Id] is missing in 1 out of 2 inputs Field [Opportunity__c.AccountId] is missing in 1 out of 2 inputs (02K7F000000l59MUAQ_03C7F000000nK3dUAE)


I checked the fileds of my CSV and Excel they are same, in name and sequence. I am not getting any idea, why i am getting this error. 
I have Payment data(created before 1 year) for Account which will be outside salesforce and fresh payment data will be in salesforce. Now for reporting purpose, i am adding historical data from CSV into wave analytics and current data from salesforce directly through dats set.

While creating Dataset receipt, i have to append CSV data rows into salesforce dataset. The only thing which i am able to find out is connecting and merge data from both sources in single row, but i am not able to find how to append rows in next, as for both datasets DDL is different so i cannot map them into single JSON.
 
public class MaintenanceRequestHelper {
    private static List<Case> closedCases = new List<Case>();
    private static List<Case> newlyCreatedCases ;
    private static List<Work_Part__c> allWorkParts = new List<Work_Part__c>();
    
    
    
    public static void updateAfterUpdateActivity(List<Case> newCases, Map<Id, Case> oldCases){
        for(Case singleCase : newCases){
            if(singleCase.status == 'Closed' && oldCases.get(singleCase.ID).status != singleCase.status){
                if(singleCase.Type == 'Repair' || singleCase.Type == 'Routine Maintenance'){
                    closedCases.add(singleCase);
                }
            }
        }
        createFollowUpMaintenanceRequest();
    }
    
    private static void createFollowUpMaintenanceRequest(){
        Set<ID> caseIds = new Set<ID>();
        for(Case singleCase : closedCases){
            caseIds.add(singleCase.Id);
        }
        Integer shortestMaintCycle;
        
        Map<Id, List<Work_Part__c>> maintWorkPartMap = createMaintWorkPartMap(caseIds);
        
        newlyCreatedCases = new List<Case>();
        for(Case singleCase : closedCases){
            List<Work_Part__c> workParts = maintWorkPartMap.get(singleCase.Id);
            if(workParts != null){
                shortestMaintCycle = Integer.valueOf(findShortestMaintCycle(workParts));    
            }else{
                shortestMaintCycle = Integer.valueOf(0.0);
            }
            
            
            Case newCase = new Case();
            newCase.Type = 'Routine Maintenance';
            newCase.Status = 'New';
            newCase.Vehicle__c = singleCase.Vehicle__c;
            newCase.Product__c = singleCase.Product__c;
            newCase.Subject =  String.isBlank(singleCase.Subject) ?'Routine maintenance request':singleCase.Subject;
            newCase.Date_Reported__c = Date.today();
            newCase.Date_Due__c = Date.today().addDays(Integer.valueOf(shortestMaintCycle));
            newCase.Old_Case__c = singleCase.Id;
            newCase.AccountId = singleCase.AccountId;
            newCase.Origin = singleCase.Origin;
            newCase.Equipment__c = singleCase.Equipment__c;
            if(newCase.Id == null)
            newlyCreatedCases.add(newCase);
        }
        
        if(newlyCreatedCases.size() > 0){
            system.debug('newlyCreatedCases::::'+newlyCreatedCases);
            insert newlyCreatedCases;
            updateRelatedWorkOrders(newlyCreatedCases);
        }
    }
    
    private static void updateRelatedWorkOrders(List<Case> cases){
        Map<Id, Id> oldToNewCaseMap = new Map<Id, Id>();
        for(Case singleCase : cases){
            oldToNewCaseMap.put(Id.valueOf(singleCase.Old_Case__c),singleCase.Id);
        }
        
        if(allWorkParts != null){
            for(Work_Part__c singleWorkPart : allWorkParts){
                Id newCaseId = oldToNewCaseMap.get(singleWorkPart.Maintenance_Request__c);
                singleWorkPart.Maintenance_Request__c = newCaseId;
            }
        }
        
        if(allWorkParts != null && allWorkParts.size() > 0){
            update allWorkParts;
        }        
    }
    
    private static Decimal findShortestMaintCycle(List<Work_Part__c> workParts){
        Decimal shortestValue;
        if(workParts.size()>0){
            shortestValue = workParts.get(0).Equipment__r.Maintenance_Cycle__c;
        }
        for(Work_Part__c singleWorkPart : workParts){
            if(singleWorkPart.Equipment__r.Maintenance_Cycle__c < shortestValue){
                shortestValue = singleWorkPart.Equipment__r.Maintenance_Cycle__c;
            }
        }
        return shortestValue;
    }
    
    private static Map<Id, List<Work_Part__c>> createMaintWorkPartMap(Set<ID> caseIds){
        //Fetch all WorkPart details
        allWorkParts = [SELECT ID, Equipment__c, Maintenance_Request__c, 
                        Quantity__c, Equipment__r.Maintenance_Cycle__c FROM Work_Part__c 
                        WHERE Maintenance_Request__c in: caseIds];
        Map<Id, List<Work_Part__c>> maintWorkPartMap = new Map<Id, List<Work_Part__c>>();
        for(Work_Part__c singleWorkPart : allWorkParts){
            List<Work_Part__c> tempList;
            if(maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c) == null){
                tempList = new List<Work_Part__c>();
            }else{
                tempList = maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c);
            }
            tempList.add(singleWorkPart);
            maintWorkPartMap.put(singleWorkPart.Maintenance_Request__c, tempList);
        }
        
        return maintWorkPartMap;
    }
    
}

 
Facing error in Test automation logic.
Below is my helper codde.
public class MaintenanceRequestHelper {
    private static List<Case> closedCases = new List<Case>();
    private static List<Case> newlyCreatedCases ;
    private static List<Work_Part__c> allWorkParts = new List<Work_Part__c>();
    
    
    
    public static void updateAfterUpdateActivity(List<Case> newCases, Map<Id, Case> oldCases){
        for(Case singleCase : newCases){
            if(singleCase.status == 'Closed' && oldCases.get(singleCase.ID).status != singleCase.status){
                if(singleCase.Type == 'Repair' || singleCase.Type == 'Routine Maintenance'){
                    closedCases.add(singleCase);
                }
            }
        }
        createFollowUpMaintenanceRequest();
    }
    
    private static void createFollowUpMaintenanceRequest(){
        Set<ID> caseIds = new Set<ID>();
        for(Case singleCase : closedCases){
            caseIds.add(singleCase.Id);
        }
        Integer shortestMaintCycle;
        
        Map<Id, List<Work_Part__c>> maintWorkPartMap = createMaintWorkPartMap(caseIds);
        
        newlyCreatedCases = new List<Case>();
        for(Case singleCase : closedCases){
            List<Work_Part__c> workParts = maintWorkPartMap.get(singleCase.Id);
            if(workParts != null){
                shortestMaintCycle = Integer.valueOf(findShortestMaintCycle(workParts));    
            }else{
                shortestMaintCycle = Integer.valueOf(0.0);
            }
            
            
            Case newCase = new Case();
            newCase.Type = 'Routine Maintenance';
            newCase.Status = 'New';
            newCase.Vehicle__c = singleCase.Vehicle__c;
            newCase.Product__c = singleCase.Product__c;
            newCase.Subject =  String.isBlank(singleCase.Subject) ?'Routine maintenance request':singleCase.Subject;
            newCase.Date_Reported__c = Date.today();
            newCase.Date_Due__c = Date.today().addDays(Integer.valueOf(shortestMaintCycle));
            newCase.Old_Case__c = singleCase.Id;
            newCase.AccountId = singleCase.AccountId;
            newCase.Origin = singleCase.Origin;
            newCase.Equipment__c = singleCase.Equipment__c;
            if(newCase.Id == null)
            newlyCreatedCases.add(newCase);
        }
        
        if(newlyCreatedCases.size() > 0){
            system.debug('newlyCreatedCases::::'+newlyCreatedCases);
            insert newlyCreatedCases;
            updateRelatedWorkOrders(newlyCreatedCases);
        }
    }
    
    private static void updateRelatedWorkOrders(List<Case> cases){
        Map<Id, Id> oldToNewCaseMap = new Map<Id, Id>();
        for(Case singleCase : cases){
            oldToNewCaseMap.put(Id.valueOf(singleCase.Old_Case__c),singleCase.Id);
        }
        
        if(allWorkParts != null){
            for(Work_Part__c singleWorkPart : allWorkParts){
                Id newCaseId = oldToNewCaseMap.get(singleWorkPart.Maintenance_Request__c);
                singleWorkPart.Maintenance_Request__c = newCaseId;
            }
        }
        
        if(allWorkParts != null && allWorkParts.size() > 0){
            update allWorkParts;
        }        
    }
    
    private static Decimal findShortestMaintCycle(List<Work_Part__c> workParts){
        Decimal shortestValue;
        if(workParts.size()>0){
            shortestValue = workParts.get(0).Equipment__r.Maintenance_Cycle__c;
        }
        for(Work_Part__c singleWorkPart : workParts){
            if(singleWorkPart.Equipment__r.Maintenance_Cycle__c < shortestValue){
                shortestValue = singleWorkPart.Equipment__r.Maintenance_Cycle__c;
            }
        }
        return shortestValue;
    }
    
    private static Map<Id, List<Work_Part__c>> createMaintWorkPartMap(Set<ID> caseIds){
        //Fetch all WorkPart details
        allWorkParts = [SELECT ID, Equipment__c, Maintenance_Request__c, 
                        Quantity__c, Equipment__r.Maintenance_Cycle__c FROM Work_Part__c 
                        WHERE Maintenance_Request__c in: caseIds];
        Map<Id, List<Work_Part__c>> maintWorkPartMap = new Map<Id, List<Work_Part__c>>();
        for(Work_Part__c singleWorkPart : allWorkParts){
            List<Work_Part__c> tempList;
            if(maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c) == null){
                tempList = new List<Work_Part__c>();
            }else{
                tempList = maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c);
            }
            tempList.add(singleWorkPart);
            maintWorkPartMap.put(singleWorkPart.Maintenance_Request__c, tempList);
        }
        
        return maintWorkPartMap;
    }
    
}

 
I faced this issue quite oftenly.
//sObj will be the API name come dynamically based on parameters
String query = 'Select Id, C_Location__c from '+sObj;
					List<sObject> sObjList = new List<sObject>();
					try{
						sObjList = Database.query(query);
                    }catch(Exception e){
                        system.debug('Exception:::::::::'+e.getMessage());
                    }
					if(sObjList.size() > 0){
						for(sObject sObjRet : sObjList){
//now where if we want to access any other field than standard fields of that object it throws error
							AllRecordsWrapper wrapperObj = new AllRecordsWrapper(sObj , sObjRet.Id, sObjRet);
							wrapperList.add(wrapperObj);

Hi I have a wrapper class in which i have a boolean variable. Now i have a list of Wrapper Class which i have to show on VF page, now i want to show the table in such a way that true values comes first and then false. Now i want to prepare a wrapperlist such that all true records come first and then records with false value.
Hi ,
  
I have Created a lightning component and i have created a lightning tab for component. I am able to see that tab in Salesforce1 but i also want to see that when i am loging in from browser like standard tabs on top. Can anyone help me on this.
Hi ,

I have Created a lightning component and i have created a lightning tab for component. I am able to see that tab in Salesforce1 but i also want to see that when i am loging in from browser like standard tabs on top. Can anyone help me on this.
Hi I have written code for integration with sendgrid.
Now when i am sending a text or CSV file it is working fine but if i am sending PDF,JPEG,Word file it is showing error while i am setting attachment in URL parameter only.
//Code of webservice class to set file as attachment
            for (String att: attachmentMap.keySet()) {
                String content = attachmentMap.get(att).toString();
                body += '&files[' + att + ']=' + EncodingUtil.urlEncode(content, 'UTF-8');
            }


//
Document doc = [Select Id, Name, body from Document where id='0159000000Bq3oI'];
List<String> toEmail = new List<String>();
List<String> ccEmail = new List<String>();
List<String> bccEmail = new List<String>();
toEmail.add('test@gmail.com , test To Name');


String fromEmail = test1@gmail.com';
String subject = 'test subject';
String bodyText = 'test body';
String bodyHtml = '<h1>test body</h1><br/>tested';
String fromName = 'Sangwan';
String replyto  = '';   
String extheaders = null;
Map<String,Blob> attachmentMap = new Map<String,Blob>();
//Blob att = doc.body;
attachmentMap.put(doc.Name, doc.body);
SendGripApiClass.sendEmail(toEmail, ccEmail, bccEmail, fromEmail, subject, bodyText, bodyHtml, fromName,
                          replyto, extheaders, attachmentMap);
//Code of webservice class to set file as attachment
            for (String att: attachmentMap.keySet()) {
                String content = attachmentMap.get(att).toString();
                body += '&files[' + att + ']=' + EncodingUtil.urlEncode(content, 'UTF-8');
            }


//
Document doc = [Select Id, Name, body from Document where id='0159000000Bq3oI'];
List<String> toEmail = new List<String>();
List<String> ccEmail = new List<String>();
List<String> bccEmail = new List<String>();
toEmail.add('test@gmail.com , test To Name');


String fromEmail = test1@gmail.com';
String subject = 'test subject';
String bodyText = 'test body';
String bodyHtml = '<h1>test body</h1><br/>tested';
String fromName = 'Sangwan';
String replyto  = '';   
String extheaders = null;
Map<String,Blob> attachmentMap = new Map<String,Blob>();
//Blob att = doc.body;
attachmentMap.put(doc.Name, doc.body);
SendGripApiClass.sendEmail(toEmail, ccEmail, bccEmail, fromEmail, subject, bodyText, bodyHtml, fromName,
                          replyto, extheaders, attachmentMap);
Hi I have written code for integration with sendgrid.
Now when i am sending a text or CSV file it is working fine but if i am sending PDF,JPEG,Word file it is showing error while i am setting attachment in URL parameter only.
u=[Select Id,ManagerId from User where UserName='abc@gmail.com'];
        System.debug('.....User...........'+u+'........'+u.ManagerId);
        List<Credit_Enhancement__c> creditList=creditListTestData();
        creditList[0].OwnerId=u.Id;
		test.startTest();

		insert creditList; 

		creditList[0].DummySentForApproval__c=true;


		creditList[0].DummyApprovedCB__c=true;
		System.runAs(u){
		Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
        req1.setComments('Submitting request for approval.');
        req1.setObjectId(creditList[0].id);
        req1.setSubmitterId(u.Id);
        Approval.ProcessResult result = Approval.process(req1);
    	}

		update creditList;
using bcc to salesforce, and i have to create a new task when mail comes with specified subject. I had written a trigger on Task. In case when i am sending bcc to lead its working fine but in case of Contact whoId is always coming as null, i tried with both after insert and after update.

This is trigger I had written:
trigger bccTrigger on Task (after insert, after update) {

    //TaskTriggerHelper.createNewTask(Trigger.new);
    List<Task> tnew=trigger.new;
    List<Task> tc=[Select Id,Subject,Dummy_Number__c,WhoId from Task where id in:tnew];
    List<Task> tk=new List<Task>();
    If(Trigger.isInsert){
        if(Trigger.isAfter){
        for(Task t:tc){
        system.debug('............Insert.......'+t.WhoId+'.....'+t.Id);
            if((t.Subject).equals('Email: GroupBy / Searchandiser Introduction')){
                t.Dummy_Number__c=t.Dummy_Number__c+1;
                }
            }
            update tc;
        }
    }

    if(Trigger.isUpdate){
        if(Trigger.isAfter){
            for(Task t:tc){
            system.debug('............Update.......'+t.WhoId+'.....'+t.Id);
            if((t.Subject).equals('Email: GroupBy / Searchandiser Introduction')){
                Task tadd=new Task();
                tadd.Subject='Test1';
                tadd.WhoId=t.WhoId;
                tk.add(tadd);
                }
            }
            insert tk;
        }
    }

}
using bcc to salesforce, and i have to create a new task when mail comes with specified subject. I had written a trigger on Task. In case when i am sending bcc to lead its working fine but in case of Contact whoId is always coming as null, i tried with both after insert and after update.

This is trigger I had written:
trigger bccTrigger on Task (after insert, after update) {

    //TaskTriggerHelper.createNewTask(Trigger.new);
    List<Task> tnew=trigger.new;
    List<Task> tc=[Select Id,Subject,Dummy_Number__c,WhoId from Task where id in:tnew];
    List<Task> tk=new List<Task>();
    If(Trigger.isInsert){
        if(Trigger.isAfter){
        for(Task t:tc){
        system.debug('............Insert.......'+t.WhoId+'.....'+t.Id);
            if((t.Subject).equals('Email: GroupBy / Searchandiser Introduction')){
                t.Dummy_Number__c=t.Dummy_Number__c+1;
                }
            }
            update tc;
        }
    }

    if(Trigger.isUpdate){
        if(Trigger.isAfter){
            for(Task t:tc){
            system.debug('............Update.......'+t.WhoId+'.....'+t.Id);
            if((t.Subject).equals('Email: GroupBy / Searchandiser Introduction')){
                Task tadd=new Task();
                tadd.Subject='Test1';
                tadd.WhoId=t.WhoId;
                tk.add(tadd);
                }
            }
            insert tk;
        }
    }

}


 
While going thru Trailhead and learning many things, I decided to put together my own version of yet another Trailhead Leader board. I've fleshed out an example that keeps track of Name, ID, Badges, Superbadges, Comm Badges and Total Points. Sorting, ID validation are also being done. I did all of this for my own edification and learning to better reinforce the skills that Trailhead provided me. Trailhead is really quite amazing

Link to Dev Org Public Site: http://trailhead-leaderboard-developer-edition.na35.force.com

This App is one VisualSource Page and Apex controller running as a Public Site. Refresh occurs periodically from a .Net Web App using the Partner WSDL API

I'm hoping to move all of that over to Apex once I figure out a bunch of things. I see some other suggestions about dates. It would be nice to incorporate that also. I'm sure that something like this could be incorporated into Salesforce Orgs for folks to keep track of training of their employees with Trailhead. Part of the loader I've built using the Partner WSDL scans thru all of the badges of a profile and can load them into the Org somewhere.

 
public class MaintenanceRequestHelper {
    private static List<Case> closedCases = new List<Case>();
    private static List<Case> newlyCreatedCases ;
    private static List<Work_Part__c> allWorkParts = new List<Work_Part__c>();
    
    
    
    public static void updateAfterUpdateActivity(List<Case> newCases, Map<Id, Case> oldCases){
        for(Case singleCase : newCases){
            if(singleCase.status == 'Closed' && oldCases.get(singleCase.ID).status != singleCase.status){
                if(singleCase.Type == 'Repair' || singleCase.Type == 'Routine Maintenance'){
                    closedCases.add(singleCase);
                }
            }
        }
        createFollowUpMaintenanceRequest();
    }
    
    private static void createFollowUpMaintenanceRequest(){
        Set<ID> caseIds = new Set<ID>();
        for(Case singleCase : closedCases){
            caseIds.add(singleCase.Id);
        }
        Integer shortestMaintCycle;
        
        Map<Id, List<Work_Part__c>> maintWorkPartMap = createMaintWorkPartMap(caseIds);
        
        newlyCreatedCases = new List<Case>();
        for(Case singleCase : closedCases){
            List<Work_Part__c> workParts = maintWorkPartMap.get(singleCase.Id);
            if(workParts != null){
                shortestMaintCycle = Integer.valueOf(findShortestMaintCycle(workParts));    
            }else{
                shortestMaintCycle = Integer.valueOf(0.0);
            }
            
            
            Case newCase = new Case();
            newCase.Type = 'Routine Maintenance';
            newCase.Status = 'New';
            newCase.Vehicle__c = singleCase.Vehicle__c;
            newCase.Product__c = singleCase.Product__c;
            newCase.Subject =  String.isBlank(singleCase.Subject) ?'Routine maintenance request':singleCase.Subject;
            newCase.Date_Reported__c = Date.today();
            newCase.Date_Due__c = Date.today().addDays(Integer.valueOf(shortestMaintCycle));
            newCase.Old_Case__c = singleCase.Id;
            newCase.AccountId = singleCase.AccountId;
            newCase.Origin = singleCase.Origin;
            newCase.Equipment__c = singleCase.Equipment__c;
            if(newCase.Id == null)
            newlyCreatedCases.add(newCase);
        }
        
        if(newlyCreatedCases.size() > 0){
            system.debug('newlyCreatedCases::::'+newlyCreatedCases);
            insert newlyCreatedCases;
            updateRelatedWorkOrders(newlyCreatedCases);
        }
    }
    
    private static void updateRelatedWorkOrders(List<Case> cases){
        Map<Id, Id> oldToNewCaseMap = new Map<Id, Id>();
        for(Case singleCase : cases){
            oldToNewCaseMap.put(Id.valueOf(singleCase.Old_Case__c),singleCase.Id);
        }
        
        if(allWorkParts != null){
            for(Work_Part__c singleWorkPart : allWorkParts){
                Id newCaseId = oldToNewCaseMap.get(singleWorkPart.Maintenance_Request__c);
                singleWorkPart.Maintenance_Request__c = newCaseId;
            }
        }
        
        if(allWorkParts != null && allWorkParts.size() > 0){
            update allWorkParts;
        }        
    }
    
    private static Decimal findShortestMaintCycle(List<Work_Part__c> workParts){
        Decimal shortestValue;
        if(workParts.size()>0){
            shortestValue = workParts.get(0).Equipment__r.Maintenance_Cycle__c;
        }
        for(Work_Part__c singleWorkPart : workParts){
            if(singleWorkPart.Equipment__r.Maintenance_Cycle__c < shortestValue){
                shortestValue = singleWorkPart.Equipment__r.Maintenance_Cycle__c;
            }
        }
        return shortestValue;
    }
    
    private static Map<Id, List<Work_Part__c>> createMaintWorkPartMap(Set<ID> caseIds){
        //Fetch all WorkPart details
        allWorkParts = [SELECT ID, Equipment__c, Maintenance_Request__c, 
                        Quantity__c, Equipment__r.Maintenance_Cycle__c FROM Work_Part__c 
                        WHERE Maintenance_Request__c in: caseIds];
        Map<Id, List<Work_Part__c>> maintWorkPartMap = new Map<Id, List<Work_Part__c>>();
        for(Work_Part__c singleWorkPart : allWorkParts){
            List<Work_Part__c> tempList;
            if(maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c) == null){
                tempList = new List<Work_Part__c>();
            }else{
                tempList = maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c);
            }
            tempList.add(singleWorkPart);
            maintWorkPartMap.put(singleWorkPart.Maintenance_Request__c, tempList);
        }
        
        return maintWorkPartMap;
    }
    
}

 
Facing error in Test automation logic.
Below is my helper codde.
public class MaintenanceRequestHelper {
    private static List<Case> closedCases = new List<Case>();
    private static List<Case> newlyCreatedCases ;
    private static List<Work_Part__c> allWorkParts = new List<Work_Part__c>();
    
    
    
    public static void updateAfterUpdateActivity(List<Case> newCases, Map<Id, Case> oldCases){
        for(Case singleCase : newCases){
            if(singleCase.status == 'Closed' && oldCases.get(singleCase.ID).status != singleCase.status){
                if(singleCase.Type == 'Repair' || singleCase.Type == 'Routine Maintenance'){
                    closedCases.add(singleCase);
                }
            }
        }
        createFollowUpMaintenanceRequest();
    }
    
    private static void createFollowUpMaintenanceRequest(){
        Set<ID> caseIds = new Set<ID>();
        for(Case singleCase : closedCases){
            caseIds.add(singleCase.Id);
        }
        Integer shortestMaintCycle;
        
        Map<Id, List<Work_Part__c>> maintWorkPartMap = createMaintWorkPartMap(caseIds);
        
        newlyCreatedCases = new List<Case>();
        for(Case singleCase : closedCases){
            List<Work_Part__c> workParts = maintWorkPartMap.get(singleCase.Id);
            if(workParts != null){
                shortestMaintCycle = Integer.valueOf(findShortestMaintCycle(workParts));    
            }else{
                shortestMaintCycle = Integer.valueOf(0.0);
            }
            
            
            Case newCase = new Case();
            newCase.Type = 'Routine Maintenance';
            newCase.Status = 'New';
            newCase.Vehicle__c = singleCase.Vehicle__c;
            newCase.Product__c = singleCase.Product__c;
            newCase.Subject =  String.isBlank(singleCase.Subject) ?'Routine maintenance request':singleCase.Subject;
            newCase.Date_Reported__c = Date.today();
            newCase.Date_Due__c = Date.today().addDays(Integer.valueOf(shortestMaintCycle));
            newCase.Old_Case__c = singleCase.Id;
            newCase.AccountId = singleCase.AccountId;
            newCase.Origin = singleCase.Origin;
            newCase.Equipment__c = singleCase.Equipment__c;
            if(newCase.Id == null)
            newlyCreatedCases.add(newCase);
        }
        
        if(newlyCreatedCases.size() > 0){
            system.debug('newlyCreatedCases::::'+newlyCreatedCases);
            insert newlyCreatedCases;
            updateRelatedWorkOrders(newlyCreatedCases);
        }
    }
    
    private static void updateRelatedWorkOrders(List<Case> cases){
        Map<Id, Id> oldToNewCaseMap = new Map<Id, Id>();
        for(Case singleCase : cases){
            oldToNewCaseMap.put(Id.valueOf(singleCase.Old_Case__c),singleCase.Id);
        }
        
        if(allWorkParts != null){
            for(Work_Part__c singleWorkPart : allWorkParts){
                Id newCaseId = oldToNewCaseMap.get(singleWorkPart.Maintenance_Request__c);
                singleWorkPart.Maintenance_Request__c = newCaseId;
            }
        }
        
        if(allWorkParts != null && allWorkParts.size() > 0){
            update allWorkParts;
        }        
    }
    
    private static Decimal findShortestMaintCycle(List<Work_Part__c> workParts){
        Decimal shortestValue;
        if(workParts.size()>0){
            shortestValue = workParts.get(0).Equipment__r.Maintenance_Cycle__c;
        }
        for(Work_Part__c singleWorkPart : workParts){
            if(singleWorkPart.Equipment__r.Maintenance_Cycle__c < shortestValue){
                shortestValue = singleWorkPart.Equipment__r.Maintenance_Cycle__c;
            }
        }
        return shortestValue;
    }
    
    private static Map<Id, List<Work_Part__c>> createMaintWorkPartMap(Set<ID> caseIds){
        //Fetch all WorkPart details
        allWorkParts = [SELECT ID, Equipment__c, Maintenance_Request__c, 
                        Quantity__c, Equipment__r.Maintenance_Cycle__c FROM Work_Part__c 
                        WHERE Maintenance_Request__c in: caseIds];
        Map<Id, List<Work_Part__c>> maintWorkPartMap = new Map<Id, List<Work_Part__c>>();
        for(Work_Part__c singleWorkPart : allWorkParts){
            List<Work_Part__c> tempList;
            if(maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c) == null){
                tempList = new List<Work_Part__c>();
            }else{
                tempList = maintWorkPartMap.get(singleWorkPart.Maintenance_Request__c);
            }
            tempList.add(singleWorkPart);
            maintWorkPartMap.put(singleWorkPart.Maintenance_Request__c, tempList);
        }
        
        return maintWorkPartMap;
    }
    
}

 
I have a wave dataset called "CustomerData" which is populated from a salesforce custom object. What I want to do is take a snapshot of this custom object, and append it to the dataset (with today's date) as a part of the dataflow.
The problem I run in to is that I need to do an "edgemart" action followed by an "append" action to actually add data on to the exisitng dataset. However whenever I do this in my dataflow:
"ExistingCustomerDataSnapshots": {
          "action": "edgemart",
          "parameters": {
             "alias": "CustomerData"
          }
       },


I get this error when I run it:
 
Error executing node ExistingCustomerDataSnapshots: Error in GetEdgemartCurrentData for edgemart CustomerData: No edgemarts found with specified URL:esObject/edgemart?current=true&alias=CustomerData

I am certain the dataset exists and that the name is correct.

Is there something I need to do additional to be able to use edgemarts besides just adding the action to the dataflow json?
I faced this issue quite oftenly.
//sObj will be the API name come dynamically based on parameters
String query = 'Select Id, C_Location__c from '+sObj;
					List<sObject> sObjList = new List<sObject>();
					try{
						sObjList = Database.query(query);
                    }catch(Exception e){
                        system.debug('Exception:::::::::'+e.getMessage());
                    }
					if(sObjList.size() > 0){
						for(sObject sObjRet : sObjList){
//now where if we want to access any other field than standard fields of that object it throws error
							AllRecordsWrapper wrapperObj = new AllRecordsWrapper(sObj , sObjRet.Id, sObjRet);
							wrapperList.add(wrapperObj);

Hi I have a wrapper class in which i have a boolean variable. Now i have a list of Wrapper Class which i have to show on VF page, now i want to show the table in such a way that true values comes first and then false. Now i want to prepare a wrapperlist such that all true records come first and then records with false value.
Hello Guys,

When I validate the trigger with test class on LIVE, getting error for Too many SQL Quries 101. Can you please help me to update the trigger.

Trigger: UpdateContactOwnerForTrial that wants to validate on LIVE.
trigger UpdateContactOwnerForTrial on Opportunity (after insert, after Update) {
    
     List<Contact> conList = new List<Contact>([select Id,ownerId from Contact where Id In (select ContactId from OpportunityContactRole where OpportunityId IN :Trigger.newMap.keySet())]); 
  	 List<Contact> contactsToUpdate = new List<Contact>{};
    
    for(Opportunity opp : trigger.new)
    {   
          for(Contact c: conList){
              c.ownerId = opp.ownerId;
              contactsToUpdate.add(c);
        }    
    }
   update contactsToUpdate; 

}

Test class
@isTest
public class TestUpdateContactOwnerForTrial {
	static testMethod void TestUpdateContactOwnerForTrialTest()
	{    
		Account a = new Account(Name = 'TestUpdateContactOwnerForTrial');
		a.Type = 'Customer';
		insert a;

		Contact newContact = new Contact(Lastname='testLastName', AccountId = a.Id );
		insert newContact;
	
        String opportunityName = 'TestUpdateContactOwnerForTrial';
        Opportunity o1 = new Opportunity(AccountId=a.Id, name=opportunityName, StageName='Closed Won', Accounting_Platform__c='QuickBooks Online (US)', CloseDate = Date.today() );
        insert o1;
        
		OpportunityContactRole ocr = new OpportunityContactRole(OpportunityId = o1.Id, ContactId = newContact.Id, Role='Decision Maker',Isprimary=true );
		insert ocr;
        
    }	
		
}

Error: 

User-added image
trigger billingSubscriptionEmail on Opportunity (before update) {


List<Addon_Opportunity__c> addOppList = new List<Addon_Opportunity__c>([SELECT Name,Amount__c,Quantity__c FROM Addon_Opportunity__c where Id__c IN :Trigger.newMap.keySet()]); 

List<Contact> conList = new List<Contact>([select Email from Contact where Id In (select ContactId from OpportunityContactRole where OpportunityId IN :Trigger.newMap.keySet())]); 

 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
     Decimal planPrice=0 ;
    String[] toAddresses;
    if(addOppList!=null){
        for(Addon_Opportunity__c addon :addOppList){
                planPrice= planPrice+ addon.Amount__c;
            }    
  }
    for(Opportunity opp : trigger.new){
    
            if(opp.StageName=='Closed Won' && Trigger.oldMap.get(opp.Id).StageName!='Closed Won'){
                
                for(Contact c:conList){
                        if(c.Email.contains('webgility.com')){
                            toAddresses = new String[] {'test3@test.com','test1@test.com'};
                        }else{
                                 toAddresses = new String[] {'test4@test.com','test2@test.com'};
                        }     
                     String billingCycle;
                     String promo='';
                       
                        mail.setToAddresses(toAddresses );   
                        mail.setSubject('New Subscription - '+opp.Accounting_Platform__c+' - '+c.Email);   
                       if(opp.Billing_Cycle__c=='Monthly'){
                         billingCycle = 'Monthly';
                       }else{
                          billingCycle = 'Annual';  
                       }
                       
                      if(opp.promo_code__c!=null){
                          promo = opp.promo_code__c;
                      }else{
                          promo = 'None';
                      } 
                         Decimal P;
                       
                         if(opp.Recurring_Revenue__c==null) opp.Recurring_Revenue__c=0;
                         if(opp.One_Time_Fee__c==null) opp.One_Time_Fee__c=0;
                         P = (integer)opp.Recurring_Revenue__c +(integer)opp.One_Time_Fee__c-(integer)planPrice;
                         String template = 'Billing & Subscription Info:\n';
                         template+= '----------------------------------\n';
                       template+= 'Account Email: '+c.Email+'\n';
                         template+= 'Total Upfront Payment: $'+ opp.One_Time_Fee__c+'\n';  
                         template+= billingCycle+' Recurring Amount: $'+opp.Recurring_Revenue__c+'\n';
                         template+= 'Plan: '+opp.Plan__c+' ($'+P+')\n';
                         template+= 'Plan Tier: '+opp.Plan_Tier__c+'\n';
                         template+= '----------------------------------\n';
                         for(Addon_Opportunity__c addon :addOppList){
                             String qty='';
                             if(addon.Name=='Installation'){
                                addon.Name = 'Installation ,setup and traning';
                             }
                             if(addon.Name=='Add-on Users' || addon.Name=='Add-on Profile')
                             {
                                qty =  String.valueOf(addon.Quantity__c.format())+' ';
                             } 
                             template+= qty+addon.Name+': $'+addon.Amount__c;
                             template+= '\n';
                        }
                        template+= '\n';
                        template+= '----------------------------------\n';
                        template+= 'Recurring billing start date :'+opp.Purchase_Date__c+'\n';
                        template+= 'Promo Code :'+promo+'\n';
                        template+= 'SF Opportunity: '+'https://webgility.my.salesforce.com/'+Trigger.oldMap.get(opp.Id).Id;
                        List<String> args = new List<String>();
                   String formattedHtml = String.format(template, args);
                   
                    mail.setPlainTextBody(formattedHtml);
                         
                    } 
                   if(BillingEmailTriggerHandler.isFirstTime)
                        {
                          BillingEmailTriggerHandler.isFirstTime = false;  
                          Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});  
                       }  
            }

    }

}
Issue is getting on the line no. 6
List<Contact> conList = new List<Contact>([select Email from Contact where Id In (select ContactId from OpportunityContactRole where OpportunityId IN :Trigger.newMap.keySet())]); 

Thanks 








 
Hi All,

My requirement is to send a mail with list of selected events from Case Related List to any user Client wants.

Could anyone help me.

Thanks,
SB
Hi all,
I have created test class for my apex class the test class has been successfully get passed but still not showing expexted code coverage. Why is it so? Please suggest.
Any help would be highly appreciated.
Hi,

          I have to calculate the aggregate for check box value via SOQL.? How to get the aggregate and sum the check box value aggregate.My requirement is Event based attenance like check box value is true means present other wise appesant . Have to calculate the aggregate of present /not present. I am getting the Count value from query , how to pass this value and get the aggregate to calcualte the Attendance percentage (100%).
Please guide me to solve this issue ASAP and share sample coding for this. 

My Sample Code Below:
public String getAttendance(string Subjectcode) {          
        Decimal SubAttendance= 0;        
        EmpNo = string.escapesinglequotes(EmpNo);  
        List<AggregateResult> aggregatelist = new List<AggregateResult>();         
        aggregatelist = [Select Count(Id) cont,Title__c Title,Subject_Code__c,Present__c Present  from Attendance_Table__c where Type__c='Event' And Emp_No__c =:EmpNo And Code__c ='E-11' Group By Title__c,Code__c,Present__c ];        
        map<string,map<boolean,string>> mapnew = new map<string,map<boolean,string>>();
         for(Aggregateresult temp:aggregatelist){
            map<boolean,string> mapinst = new map<boolean,string>();
            mapinst.put(temp.get('Present'),string.valueof(temp.get('cont')));
            mapnew.put(string.valueof(temp.get('Title')),mapinst);
        }
         System.debug('Boolean Result' + mapnew);
          for(string temp:mapnew.keyset()){
              wrapperlist.add(new wrapperinstance(temp,mapnew.get(temp).get(true)/(mapnew.get(temp).get(true) + mapnew.get(temp).get(false))));
          }
        return String.valueOf(((SubAttendance/500)*5));   
    } 

Advance Thanks 
Maheshwar
Hi

I am trying to understand if there can be a dependency in workflow rules:?
I think in triggers we do have dependency.

Thanks
sonali verma​​​