• claper
  • NEWBIE
  • 165 Points
  • Member since 2011


Badges

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 8
    Questions
  • 62
    Replies
We have a custom object "Task_Custom__c" that I would like to add a button to.  When the button is clicked, we need two fields on this object to be updated:

Completion_Stats__c = "Completed"
Completion_Percentage__c = "100"

Can that be done with on click javascript?
I have a detail page button that executes Javascript on click. In the button there are multiple DML statements but I would like to set save points so if an error occurs, I can roll back the changes. Is this possible without creating webservice apex methods?
While working on creating manage package I'm having a hard time adding into the package custom quick actions (the ones that have a visualforce page) According to the documentation "Quick Actions & Global Actions" are available for manage packges https://help.salesforce.com/HTViewHelpDoc?id=changesets_about_components.htm&language=en_US, but there is no where were I can select them when adding component to the package, neither they are added automatically

have this happened to any of you? Any help will be appreciated!!!
  • August 20, 2015
  • Like
  • 0
We need to figure out the format for the callback URLs to allow another iOS app to open a visual force page in SF1 with a parameter. For example... the PDF doc says to use the following format... 

salesforce1://sObject/{!record.id}/view 

However, other (scarce) resources I can find say to use a different format... 

com.salesforce.salesforce1://entity/view?entityId={!record.id} 

Both seem to work... this blog entry (https://plus.google.com/108841584505265827017
/posts/GjHbMRmQzC3) says that you can open APEX pages using "apex/pageName" as the record id in the second format, but it does not seem to work. So there are conflicting sources of information and limited documentation. 

Basically, I can find no clear documentation on this.


from IOS app try to open/redirect to a Visualforce Page on SF1
Here is what we are trying to do, and what works so far.... 

1. Have a visualforce page with a x-callback protocol link in it to an external barcode scanner app. This works. 
2. On success from the barcode scanner, call a x-callback protocol link to return the user to SalesForce1. This works so long as we are linking back to a specific record id. HOWEVER, we want to link instead to a VisualForce page and pass it as a parameter the data from the barcode scanner.
  • February 03, 2015
  • Like
  • 0
I have the following code implementation in a VF page that has been enable for SF1
function navigate(){
                
                if ( (typeof sforce != 'undefined') && (sforce != null) )  {s
                    alert('parentId  {!parentDBRF}');
                    sforce.one.navigateToSObject('{!parentDBRF}');
                } else {
                    window.location="/" + '{!parentDBRF}';
                }        
            }

the method is being called by :
<apex:ActionFunction name="addDBRFLine" action="{!addNewLine}" reRender="msgs" oncomplete="navigate();" />

The issue comes with a user that have the following mobile device specification:
  • Iphone 5c version: 8.1.2
  • Saleforce 1 v7.0.1
The user does not get redirected when the navigate method execute. Although the alert message does pop-up and the recordId display properly.
 
  • January 23, 2015
  • Like
  • 0

I'm wrriting a VF page that needs to display in a page block table the current members of the account team and a checkbox next to each member. currently I'm getting this error Message: "AccountTeamAssignment Compile Error: Loop variable must be an SObject or list of AccountTeamMember"

 

here is my code: 

public List<teamMemberWrapper> fetchTeamMember(){
        teamMember = new List<teamMemberWrapper>();
        for(List<AccountTeamMember>  aList : [select userId, user.Name, teamMemberRole from AccountTeamMember where Accountid =: thisAccount.id]){
            for(AccountTeamMember a : aList)
            teamMember.add(new teamMemberWrapper(false, a));
        }
        
        return teamMember;        
}

public class teamMemberWrapper{
        
        public boolean selected {get; set;}
        public AccountTeamMember member {get; set;}

        public teamMemberWrapper(boolean selected, AccountTeamMember atm){
            this.selected = selected;
            this.member = atm;
        }
}    

 I've also tried to set the SOQL for like this: 

for(LAccountTeamMember  a : [select userId, user.Name, teamMemberRole from AccountTeamMember where Accountid =: thisAccount.id]){
            teamMember.add(new teamMemberWrapper(false, a));
}

 But no luck, any ideas?

 

Thanks!

  • November 21, 2013
  • Like
  • 0

Accordin to this post http://blogs.developerforce.com/developer-relations/2013/02/oauth-for-portal-users.html we are able to use OAuth and API calls with portal user licenses. It seems to work great on DE and Production enviroments, but something its not working  correctly for Sandbox enviroment. What would be the URL for authentication on sandbox?

 

Thank You!

Clara.

  • August 13, 2013
  • Like
  • 0

The other day I was writting my test class to pass a custom controller for a VF page in to production. The VF page worked great everything as supposed to; returning right amount of rows and values. BUT then went I try to create my test class, i came accross the hierarchy field where not able to be used in the query (that's what i think it is)  listSize was always 0 in the test method when it was supposed to be 2. i try several ways but the same situation came accross...

 

any thoughts???

Hi!

 

Now i'm working on a VF page that in one column has a select list and allows the user to select a value from the list and reRender a cross-tabular report on the same page. The issue comes with the picklists, the controller only gets the last value of the pageblocktable picklist. 

 

any help? pls!

=============================================================================================

here is the VF page:

<apex:page standardcontroller="account" extensions="mtc_TerritoryDesigner2" readOnly="true">
<script>
function hi(){
return "hi";
}
</script>
<apex:form >
        <apex:SectionHeader title="MTC Overview" subtitle="MTC"/>
        <apex:toolbar id="toolbar" style="background-color:#EEECD1;background-image:none;" height="20px;">
            <apex:toolbarGroup >
            <apex:commandLink value="Territory Designer"/>
            <apex:commandLink value="Manager Grid"/>
            <apex:commandLink value="SA Grid"/>
            <apex:commandLink value="Industry Grid" />
            <apex:commandLink value="Detail Assigment"/>
            <apex:commandLink value="MTC Overview"/>
            </apex:toolbarGroup>            
        </apex:toolbar>   
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:pageblocktable value="{!Accounts}" var="arr" id="accounts">
                    <apex:column >
                        <apex:facet name="header">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:facet>
                        <apex:facet name="footer">Totals</apex:facet>
                        <apex:outputText value="{!arr.UserName}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Customer</apex:facet>
                        <apex:facet name="footer"><apex:outputText value="{!FinalTotalCustomers}" /></apex:facet>
                        <apex:outputText value="{!arr.TotalCustomers}" >                            
                        </apex:outputText>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Non Customer</apex:facet>
                        <apex:facet name="footer"><apex:outputText value="{!FinalTotalNonCustomers}" /></apex:facet>
                        <apex:outputText value="{!arr.TotalNonCustomers}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Open Coverage</apex:facet>  
                        <apex:facet name="footer"><apex:outputText value="{!FinalTotalOpenCoverages}" /></apex:facet>               
                        <apex:outputText value="{!arr.TotalOpenCoverages}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of MIF</apex:facet>   
                        <apex:facet name="footer"><apex:outputText value="{!FinalTotalEquipment}" /></apex:facet>                  
                        <apex:outputText value="{!typeSelected}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Leases</apex:facet> 
                        <apex:facet name="footer"><apex:outputText value="{!FinalTotalLease}" /></apex:facet>  
                        <apex:outputText value="{!conttype}" />                   
                    </apex:column>
                </apex:pageblocktable>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Accounts by Zip" id="SecondSection" columns="1" >
        <apex:pageMessages ></apex:pageMessages>
                    <script>
                        j$('#dialogPopup').dialog('close');
                    </script>
                <apex:pageBlockTable value="{!AccountsByZip}" var="ar" styleClass="sortable" id="accountsbyzip">
                    <apex:column >
                        <apex:facet name="header">Zip</apex:facet>
                        <apex:outputText value="{!ar.Zip}" /> 
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">Owner</apex:facet>
                        <apex:outputText value="{!ar.ownerName}" >
                        </apex:outputText> 
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Establishments</apex:facet>
                        <apex:outputText value="{!ar.NumAccounts}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Customers</apex:facet>
                        <apex:outputText value="{!ar.NumCustomers}" >                           
                        </apex:outputText>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Non Customers</apex:facet>
                        <apex:outputText value="{!ar.NumNonCustomers}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header"># of Open Coverage</apex:facet>
                        <apex:outputText value="{!ar.NumOpenCoverages}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">Reassign</apex:facet>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">Type</apex:facet>
                        <apex:selectList value="{!typeselected}" size="1">
                            <apex:selectOptions value="{!ar.AccTypex}"/>                      
                        </apex:selectList>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">Preview</apex:facet>
                        <apex:commandButton value="Preview" style="width: 100px;" action="{!dofetchAccounts}" rerender="accounts" >
                            <apex:param name="contCustomers" value="{!ar.NumCustomers}" assignTo="{!contCustomers}"/>
                            <apex:param name="contNonCustomers" value="{!ar.NumNonCustomers}" assignTo="{!contNonCustomers}"/>
                            <apex:param name="contOpenCoverages" value="{!ar.NumCustomers}" assignTo="{!contOpenCoverages}"/>
                            <apex:param name="contName" value="{!ar.OwnerName}" assignTo="{!contName}"/>  
                            <apex:param name="contType" value="{!ar.typeselected}" assignTo="{!contType}"/>                                           
                        </apex:commandButton>
                    </apex:column> 
                    <apex:column >
                        <apex:facet name="header">Processing</apex:facet>
                        <apex:commandButton value="Processing"/>
                    </apex:column>                  
                </apex:pageBlockTable>                            
                </apex:pageBlockSection>
       </apex:pageblock>
   </apex:form>
</apex:page>

 here is the controller:

public class mtc_TerritoryDesigner2 {

    private ApexPages.StandardController stdCtrl {get; set;}
    public list<AggregateResult> listAr = new list<AggregateResult>();
    public list<AggregateResult> listAr2 = new list<AggregateResult>();
    String CurrentUser = UserInfo.getUserId();
    String currentUserRole = UserInfo.getUserRoleId();
    List<UserRole> RepRole = [Select id from UserRole where parentroleid =: currentUserRole];
    List<id> RepsId = new List<id>();
    List<User> Users = [select name from User where isactive = true AND userroleid =: RepRole order by Name];
    Integer FinalCustomers, FinalNonCustomers, FinalOpenCoverages, FinalEquipment = 0, FinalLease = 0, ReassingCustomersAcc = 0, contCustomers2;

    public Integer getFinalTotalCustomers() { return finalCustomers;}
    public Integer getFinalTotalNonCustomers() {return finalNonCustomers;}
    public Integer getFinalTotalOpenCoverages() { return finalOpenCoverages;}
    public Integer getFinalTotalEquipment() { return finalEquipment;}
    public Integer getFinalTotalLease() { return finalLease;}
    public List<accls> Accounts2 = new List<accls>();
    public List<accByZip> Accounts3 = new List<accByZip>();
    
    
    public List<Accls> Accounts {get{return accounts2;} set;}
    public List<AccByZip> AccountsByZip {get{return accounts3;} set;}
    
    //public Integer contCustomers {get; set;}
    public Integer ContCustomers {get;set;}
    public Integer ContNonCustomers {get;set;}
    public Integer ContOpenCoverages {get;set;}
    public String contName {get;set;}
    public String contType {get;set;}
    public String TypeSelected {get;set;}
    
    //public String getTypeSelected() {return this.TypeSelected;}
   // public void setTypeSelected(String s) {this.TypeSelected = s;}
    
    public mtc_TerritoryDesigner2(ApexPages.StandardController controller) {
        stdCtrl = controller;
        for(User u:Users)
        {
            RepsId.add(u.id);
        }
        fetchaccounts();
        fetchaccountsbyZip();
    }
    
    public List<SelectOption> fetchAccTypes() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('None','None'));
            options.add(new SelectOption('Customer','Customer'));
            options.add(new SelectOption('Non Customer','Non Customer'));
            options.add(new SelectOption('Open Coverage','Open Coverage'));
            options.add(new SelectOption('All','All'));
            
            return options;
        }
  
    private void fetchAccounts()
    {
        accounts2.clear();
        listAr = [select owner.name num, type, COUNT(id) total from account where ownerid =: RepsId GROUP BY CUBE (owner.name,type) order by owner.name]; 
        
        for(User u:Users){
            Accls objAccls = new Accls();
            for(AggregateResult ag: listAr)
            {
                
                if(String.valueof(ag.get('num')) != null && string.valueof(ag.get('type')) != null && String.valueof(ag.get('num')) == u.name){
                    if(ag.get('type') == 'customer'){
                        if((string)ag.get('num') == contName  )
                        {objAccls.totalCustomers = integer.valueof(ag.get('total')) + contCustomers ;}else{objAccls.totalCustomers = integer.valueof(ag.get('total'));}}
                    if(ag.get('type') == 'Non customer'){
                        objAccls.totalNonCustomers = integer.valueof(ag.get('total'));}
                    if(ag.get('type') == 'Open Coverage'){
                        objAccls.TotalOpenCoverages = integer.valueof(ag.get('total'));}else{objAccls.TotalOpenCoverages = 0;}
                    objAccls.UserName = String.valueof(ag.get('num'));  
                    
                    //objAccls.TotalEquipment = [Select count() from asset where accountid in :[Select id from account where owner.name =: u.name and isdeleted = false ]];                              
                    //objAccls.TotalLease = [Select count() from asset where accountid in :[Select id from account where owner.name =: u.name and isdeleted = false ] AND Price_Plan__c = 'lease'];                              
                }
                if(ag.get('type') == 'Open Coverage' && ag.get('num') == null){
                    FinalOpenCoverages = integer.valueof(ag.get('total'));}
                if(ag.get('type') == 'Non Customer' && ag.get('num') == null){
                    FinalNonCustomers = integer.valueof(ag.get('total'));}
                if(ag.get('type') == 'Customer' && ag.get('num') == null){
                    if(contCustomers > 0){
                    FinalCustomers = integer.valueof(ag.get('total')) + contCustomers;} else{FinalCustomers = integer.valueof(ag.get('total'));}}

            }Accounts2.add(objAccls);
        }
    }
    
    private void fetchAccountsByZip(){
        
        listAR2 = [SELECT owner.name num, shippingpostalcode, type, count(id) total FROM account where  ownerid =:RepsId AND isdeleted=false GROUP BY  shippingpostalcode,owner.name,type order by shippingpostalcode];
        
        for(AggregateResult u:[SELECT shippingpostalcode FROM account where  ownerid =:RepsId AND isdeleted=false GROUP BY  shippingpostalcode order by shippingpostalcode]){
            AccByZip objOppClass2 = new AccByZip();
            for (AggregateResult ar: listAR2)
            {
                if(String.valueof(ar.get('num')) != null && string.valueof(ar.get('type')) != null && String.valueof(ar.get('shippingpostalcode')) == (string)u.get('shippingpostalcode')){
                    if(ar.get('type') == 'Customer'){
                        objOppClass2.NumCustomers= (ar.get('total') != '' ? (integer.valueof(ar.get('total'))) : 0);}
                    if(ar.get('type') == 'Non Customer' && ar.get('total') != null){
                        objOppClass2.NumNonCustomers = (ar.get('total') != '' ? (integer.valueof(ar.get('total'))) : 0);}
                    if(ar.get('type') == 'Open Coverage' && ar.get('total') != null){          
                        objOppClass2.NumOpenCoverages = (ar.get('total') != '' ? (integer.valueof(ar.get('total'))) : 0 );}
                    objOppClass2.Zip = (String)ar.get('shippingpostalcode');
                    objOppClass2.ownerName = (String)ar.get('num');
                    objOppClass2.AccTypex = fetchAccTypes();
                    
                    if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumNonCustomers != null && ObjOppClass2.NumOpenCoverages != null){
                      objOppClass2.NumAccounts = ObjOppClass2.NumCustomers+ObjOppClass2.NumNonCustomers+ObjOppClass2.NumOpenCoverages;
                    }else{
                        if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumNonCustomers != null )
                        {
                            objOppClass2.NumAccounts = ObjOppClass2.NumCustomers+ObjOppClass2.NumNonCustomers;
                        }
                        else{
                            if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumOpenCoverages != null )
                            {
                                objOppClass2.NumAccounts = ObjOppClass2.NumCustomers+ObjOppClass2.NumOpenCoverages;
                            }
                            else{
                                if(ObjOppClass2.NumNonCustomers != null && ObjOppClass2.NumOpenCoverages != null )
                                {
                                    objOppClass2.NumAccounts = ObjOppClass2.NumNonCustomers+ObjOppClass2.NumOpenCoverages;
                                }
                                else{
                                    if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumNonCustomers == null && ObjOppClass2.NumOpenCoverages == null )
                                    {
                                        objOppClass2.NumAccounts = ObjOppClass2.NumCustomers;
                                    }
                                    else{
                                        if(ObjOppClass2.NumNonCustomers != null && ObjOppClass2.NumCustomers == null && ObjOppClass2.NumOpenCoverages == null )
                                        {
                                            objOppClass2.NumAccounts = ObjOppClass2.NumNonCustomers;
                                        }
                                        else{
                                            if(ObjOppClass2.NumOpenCoverages != null && ObjOppClass2.NumNonCustomers == null && ObjOppClass2.NumCustomers == null )
                                            {
                                                objOppClass2.NumAccounts = ObjOppClass2.NumOpenCoverages;
                                            }
                                        }
                                    }
                                }
                            }
                        }  
                    }
                }
           }Accounts3.add(objOppClass2);                      
        }
    }
    
    public PageReference dofetchAccounts()
    {
         
         fetchAccounts();
         return null;
    }
    

    public class Accls
    {
        public Integer TotalAccounts {get;set;}
        public Integer TotalCustomers {get;set;}
        public Integer TotalNonCustomers {get;set;}
        public Integer TotalOpenCoverages {get;set;}
        public Integer TotalEquipment { get; set;}
        public Integer TotalLease { get; set;}
        public String UserName {get;set;}    
        
                
    }
    
    public class AccByZip
    {
        public Integer NumAccounts{ get;set; }
        public String Zip{ get;set; }
        public String ownerName{ get;set; }
        public Integer NumCustomers{ get;set; }
        public Integer NumNonCustomers{ get;set; }
        public Integer  NumOpenCoverages{ get;set; }
        public List<SelectOption> Acctypex {get;set;}
        public String Acctypexx {get;set;}        
        
    }

}

 

  • December 09, 2011
  • Like
  • 0

Hi Guys,

 

I'm trying to create a cross-tabular view of my data in a  Visualforce page. but i'm unable to show the data correctly; on the pageblocktable it doesnt group properly by owner.name so it will show something like this:
              # of customer       #of nonCustomer    #of OpenCovarage
rep 1           399
rep 1                                                  2554
rep 1                                                                                              1

 

 

any help? pls!!

===============================================================================================

this is my controller:

public class mtc_Overview {

String currentUserId = UserInfo.getUserId();
User CurrentUser;
String currentUserRole = UserInfo.getUserRoleId();
List<UserRole> RepRole = [Select id from UserRole where parentroleid =: currentUserRole];
public list<AggregateResult> listAr = new list<AggregateResult>();

public List<Accls> getAccounts()
{
List<id> RepsId = new List<id>();
for(User u:[select name from User where isactive = true AND userroleid =: RepRole ORDER BY name])
{
RepsId.add(u.id);
}

listAr = [select owner.name num, type, COUNT(id) total from account where ownerid =: RepsId GROUP BY CUBE (owner.name,type)];

List<Accls> Results = new List<Accls>();
for(AggregateResult ag: listAr)
{
Accls objAccls = new Accls();
if(String.valueof(ag.get('num')) != null && string.valueof(ag.get('type')) != null){
if(ag.get('type') == 'customer'){
objAccls.totalCustomers = integer.valueof(ag.get('total'));}
if(ag.get('type') == 'Non customer'){
objAccls.totalNonCustomers = integer.valueof(ag.get('total'));}
if(ag.get('type') == 'Open Coverage'){
objAccls.TotalOpenCoverages = integer.valueof(ag.get('total'));}
objAccls.UserName = String.valueof(ag.get('num'));
Results.add(objAccls);}
}
return Results;

}

public class Accls
{
public Integer TotalAccounts {get;set;}
public Integer TotalCustomers {get;set;}
public Integer TotalNonCustomers {get;set;}
public Integer TotalOpenCoverages {get;set;}
public String UserName {get;set;}
}


}

========================================

VF page

<apex:page controller="mtc_Overview" readOnly="true" >
<apex:form >
<apex:SectionHeader title="MTC Overview" subtitle="MTC"/>
<apex:toolbar id="toolbar" style="background-color:#EEECD1;background-image:none;" height="20px;">
<apex:toolbarGroup >
<apex:commandLink value="Territory Designer"/>
<apex:commandLink value="Manager Grid"/>
<apex:commandLink value="SA Grid"/>
<apex:commandLink value="Industry Grid"/>
<apex:commandLink value="Detail Assigment"/>
<apex:commandLink value="MTC Overview"/>
</apex:toolbarGroup>
</apex:toolbar>
<apex:pageBlock >
<apex:pageblocktable value="{!Accounts}" var="arr">
<apex:column >
<apex:facet name="header">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:facet>
<apex:outputText value="{!arr.UserName}" />
</apex:column>
<apex:column >
<apex:facet name="header"># of Customer</apex:facet>
<apex:outputText value="{!arr.TotalCustomers}" />
</apex:column>
<apex:column >
<apex:facet name="header"># of Non Customer</apex:facet>
<apex:outputText value="{!arr.TotalNonCustomers}" />
</apex:column>
<apex:column >
<apex:facet name="header"># of Open Coverage</apex:facet>
<apex:outputText value="{!arr.TotalOpenCoverages}" />
</apex:column>
<apex:column >
<apex:facet name="header"># of MIF</apex:facet>
<apex:outputText value="{!arr.TotalAccounts}" />
</apex:column>
<apex:column >
<apex:facet name="header"># of Leases</apex:facet>

</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>


 

  • December 07, 2011
  • Like
  • 0
Im getting an error message on my challenge saying:  The page does not include a apex:inputField component

I'm confused.  Here is my code:
User-added image
I want to automatically create a new record in custom Object B when a specific record type is selected in  custom Object A. How would I go about doing this? Please help
I'm trying to write a test class for the following class, but I'm only covering 25% of the lines. How can I edit it to cover the  if conditions?

class :

global class Wct_OfferPendingforAnalyst implements Database.Batchable<sObject>,Schedulable{

    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        String strSql = 'SELECT Id,CreatedDate,Name,RecordTypeID,Owner.Email,WCT_Created_Date_Time__c,WCT_Candidate_Email__c,WCT_Team_Mailbox__c,WCT_RMS_ID__c,WCT_Full_Name__c,WCT_status__c,WCT_AgentState_Time__c, WCT_User_Group__c' +
                     ' FROM WCT_Offer__c'+
                     ' where WCT_status__c IN (\'Offer to Be Extended\', \'Draft in Progress\', \'Returned for Revisions\')'+
                     ' AND owner.email != null'+
                     ' AND RecordType.Name IN (\'US Experienced Hire Offer\', \'US Campus Hire Offer\')'; 
        system.debug('query123******'+strSql);
        return database.getQuerylocator(strSql);
        
    }

    global void execute(Database.BatchableContext BC, List<WCT_Offer__c> scope)
    {
        List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
        List<Messaging.SingleEmailMessage> mailList2 = new List<Messaging.SingleEmailMessage>();
        
        set<string> setRecEmails = new set<string>();
        set<string> setteamEmails = new set<string>();
        map<string,string> RecTeamEmails = new map<string,string>();
        map<string,string> RecTeamEmails2 = new map<string,string>();
        
        Map<String, List<WCT_Offer__c>> recOffers = new Map<String, List<WCT_Offer__c>>(); 
        Map<String, List<WCT_Offer__c>> recOffers2 = new Map<String, List<WCT_Offer__c>>();
        
        Map<ID, Schema.RecordTypeInfo> rtMap = Schema.SObjectType.WCT_Offer__c.getRecordTypeInfosById();
        Decimal seconds;
        Decimal hrs;
        Decimal min;
        
        
        for(WCT_Offer__c tmp : scope) {
             WCT_Offer__c offerRecord = (WCT_Offer__c) tmp;
             WCT_Offer__c offerRecord2 = (WCT_Offer__c) tmp;
            
             datetime recorddatetime = date.valueof(offerRecord.CreatedDate);
             system.debug('dt**********'+recorddatetime);
             
             seconds = BusinessHours.diff(Label.WCT_Default_Business_Hours_ID, offerRecord.WCT_Created_Date_Time__c, System.now())/ 1000;
             
             system.debug('Label.WCT_Default_Business_Hours_ID**********'+Label.WCT_Default_Business_Hours_ID);
             
             min = Integer.valueOf(seconds / 60);
             hrs = Integer.valueOf(seconds / 3600);
             system.debug('seconds**********'+seconds);
             system.debug('hrs11**********'+hrs);
             system.debug('min**********'+min);
             
             system.debug('recordtype**********'+rtMap.get(offerRecord.RecordTypeId).getName());
             //-------------------1st---------------------------
             
             if(rtMap.get(offerRecord.RecordTypeId).getName() == 'US Experienced Hire Offer' &&  min >=238 && min < 257) { 
                 system.debug('recordtype1**********'+rtMap.get(offerRecord.RecordTypeId).getName());
                setRecEmails.add(offerRecord.Owner.Email);
                RecTeamEmails.put(offerRecord.Owner.Email,offerRecord.WCT_Team_Mailbox__c);
                system.debug('RecTeamEmails:'+RecTeamEmails);
                List<WCT_Offer__c> offerList = recOffers.get(offerRecord.Owner.Email);
                if(offerList == null) {
                    offerList = new List<WCT_Offer__c>();
                } 
                offerList.add(offerRecord);
                recOffers.put(offerRecord.Owner.Email,offerList);
            }
            //-------------------2nd---------------------------
           if(rtMap.get(offerRecord2.RecordTypeId).getName() == 'US Experienced Hire Offer' && min >=358 && min < 377) {   //hrs >= 6 && hrs < 7
                system.debug('alert2**********');
                setRecEmails.add(offerRecord2.Owner.Email);
                RecTeamEmails2.put(offerRecord2.Owner.Email,offerRecord2.WCT_Team_Mailbox__c);
                system.debug('RecTeamEmails2:'+RecTeamEmails2);
                List<WCT_Offer__c> offerList2 = recOffers2.get(offerRecord2.Owner.Email);
                if(offerList2 == null) {
                    offerList2 = new List<WCT_Offer__c>();
                } 
                offerList2.add(offerRecord2);
                recOffers2.put(offerRecord2.Owner.Email,offerList2);
            }
            
        }
        
        
        
        String strEmailTop ='';
        String strEmailBody ='';
        String strEmailBottom ='';
        /*
        strEmailTop  += '<!DOCTYPE html> <html> <head> <style> table,th,td { border: 1px solid black; border-collapse:collapse; }, th,td { padding:5px; } </style> </head> <body> <br> Dear Analyst,<br> <br>';
        strEmailTop  += 'Offer Letter(s) are pending for more than 4 Hours.';
        strEmailTop  += ' <br> <br> <br> <table> <thead> <tr> <th>Offer Name</th> <th>Candidate Name</th> <th>RMS ID</th> <th>Candidate Email</th> <th>Status</th> <th>Offer letter link</th> </tr> </thead> <tbody>';
        
        strEmailBottom += '</tbody> </table> <br> Thank you,<br> Deloitte Recruting.<br> </body> </html>';
        */
        
        for(string strRecEmail: recOffers.keyset()) {
            strEmailBody ='';
            for(WCT_Offer__c offerRecord : recOffers.get(strRecEmail)) {
                
                strEmailTop  += '<!DOCTYPE html> <html> <head> <style> table,th,td { border: 1px solid black; border-collapse:collapse; }, th,td { padding:5px; } </style> </head> <body> <br> Dear Analyst,<br> <br>';
                strEmailTop  += 'Offer Letter(s) are pending for more than 4 Hours.';
                strEmailTop  += ' <br> <br> <br> <table> <thead> <tr> <th>Offer Name</th> <th>Candidate Name</th> <th>RMS ID</th> <th>Candidate Email</th> <th>Status</th> <th>Offer letter link</th> </tr> </thead> <tbody>';
                
                strEmailBody += '<tr> <td>'+offerRecord.Name+'</td> <td>'+offerRecord.WCT_full_Name__c+'</td><td>'+offerRecord.WCT_RMS_ID__c+'</td><td>'+offerRecord.WCT_Candidate_Email__c+'</td>';
                strEmailBody += '<td>'+offerRecord.WCT_status__c+'</td><td><a href='+Label.BaseURL+'/'+offerRecord.id+'>URL</a></td></tr>';
                
                strEmailBottom += '</tbody> </table> <br> Thank you,<br> Deloitte Recruting.<br> </body> </html>';
            }
            list<string> ToEmailAddress = new list<string>();
            List<string> ToCcAddress = new List<string>();
            
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            ToEmailAddress.add(strRecEmail);
            system.debug('strRecEmail1:'+strRecEmail);
            if(RecTeamEmails != null && RecTeamEmails.get(strRecEmail) != null){
                 ToCcAddress.add(RecTeamEmails.get(strRecEmail));
            }
            system.debug('strRecEmail:'+strRecEmail);
            system.debug('ToCcAddress:'+ToCcAddress);
            
            mail.settoAddresses(ToEmailAddress);
            system.debug('ToEmailAddress:'+ToEmailAddress);
            mail.setccAddresses(ToCcAddress);
            system.debug('ToCcAddress1:'+ToCcAddress);
            mail.setSubject('1st Alert Immediate Action: Offer Letter(s) are pending');
            
            mail.setHTMLBody('<font color="green">'+strEmailTop+'</font>'+'<font color="green">'+strEmailBody+'</font>'+'<font color="green">'+strEmailBottom+'</font>');
            mail.setSaveAsActivity(false);
            mailList.add(mail);  
        
        }
        //------------------2nd------------------------------------------------------------------------------------------------
        for(string strRecEmail2 : recOffers2.keyset()) {
            strEmailBody ='';
            for(WCT_Offer__c offerRecord2 : recOffers2.get(strRecEmail2)) {
                strEmailTop  += '<!DOCTYPE html> <html> <head> <style> table,th,td { border: 1px solid black; border-collapse:collapse; }, th,td { padding:5px; } </style> </head> <body> <br> Dear Analyst,<br> <br>';
                strEmailTop  += 'Offer Letter(s) are pending for more than 6 Hours.';
                strEmailTop  += ' <br> <br> <br> <table> <thead> <tr> <th>Offer Name</th> <th>Candidate Name</th> <th>RMS ID</th> <th>Candidate Email</th> <th>Status</th> <th>Offer letter link</th> </tr> </thead> <tbody>';
                
                strEmailBody += '<tr> <td>'+offerRecord2.Name+'</td> <td>'+offerRecord2.WCT_full_Name__c+'</td><td>'+offerRecord2.WCT_RMS_ID__c+'</td><td>'+offerRecord2.WCT_Candidate_Email__c+'</td>';
                strEmailBody += '<td>'+offerRecord2.WCT_status__c+'</td><td><a href='+Label.BaseURL+'/'+offerRecord2.id+'>URL</a></td></tr>';
                
                strEmailBottom += '</tbody> </table> <br> Thank you,<br> Deloitte Recruting.<br> </body> </html>';
            }
            list<string> ToEmailAddress2 = new list<string>();
            List<string> ToCcAddress2 = new List<string>();
            Messaging.SingleEmailMessage mail2 = new Messaging.SingleEmailMessage();
            ToEmailAddress2.add(strRecEmail2);
            system.debug('strRecEmail2:'+strRecEmail2);
            if(RecTeamEmails2 != null && RecTeamEmails2.get(strRecEmail2) != null){
                 ToCcAddress2.add(RecTeamEmails2.get(strRecEmail2));
            }
            system.debug('strRecEmail2:'+strRecEmail2);
            system.debug('ToCcAddress:'+ToCcAddress2);
            mail2.settoAddresses(ToEmailAddress2);
            system.debug('ToEmailAddress:'+ToEmailAddress2);
                ToCcAddress2.add('pjamalapuram@deloitte.com');
                ToCcAddress2.add('rkomma@deloitte.com');
            mail2.setccAddresses(ToCcAddress2);
            system.debug('ToCcAddress1:'+ToCcAddress2);
            mail2.setSubject('2nd Alert Immediate Action: Offer Letter(s) are pending');
            
            mail2.setHTMLBody('<font color="orange">'+strEmailTop+'</font>'+'<font color="orange">'+strEmailBody+'</font>'+'<font color="orange">'+strEmailBottom+'</font>');
            
            mail2.setSaveAsActivity(false);
            mailList2.add(mail2);  
        }
            Messaging.sendEmail(mailList); 
            Messaging.sendEmail(mailList2);
    }

    global void finish(Database.BatchableContext BC){
    }
}
Test class: 

@isTest
public class Wct_OfferPendingforAnalyst_Test{
    static Id employeeRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Employee').getRecordTypeId();
    static testMethod void Wct_OfferPendingforAnalyst_TestMethod (){
     Profile prof = [select id from profile where name='system Administrator'];
     User usr = new User(alias = 'usr', email='us.name@vmail.com',
                emailencodingkey='UTF-8', lastname='lstname',
                timezonesidkey='America/Los_Angeles',
                languagelocalekey='en_US',
                localesidkey='en_US', profileid = prof.Id,
                username='testuser128@testorg.com');
                insert usr;
    
       Account acc = new Account();
       acc.Name='Test';
       Insert acc;
       system.debug('acc values ----'+acc);
       
       Contact con = new Contact ();
       con.AccountId= acc.Id;
       con.LastName='tec';
       con.Email='user@gmail.com';
       Insert con;
       
        List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
        List<Messaging.SingleEmailMessage> mailList2 = new List<Messaging.SingleEmailMessage>();
        set<string> setRecEmails = new set<string>();
        set<string> setteamEmails = new set<string>();
        map<string,string> RecTeamEmails = new map<string,string>();
        map<string,string> RecTeamEmails2 = new map<string,string>();
        Map<String, List<WCT_Offer__c>> recOffers = new Map<String, List<WCT_Offer__c>>(); 
        Map<String, List<WCT_Offer__c>> recOffers2 = new Map<String, List<WCT_Offer__c>>();
        Map<ID, Schema.RecordTypeInfo> rtMap = Schema.SObjectType.WCT_Offer__c.getRecordTypeInfosById();
        
        recordtype rc1 = [SELECT Id FROM RecordType WHERE SObjectType = 'WCT_Offer__c' limit 1];
        WCT_Offer__c oppty = new WCT_Offer__c();
        oppty.recordtypeid = rc1.id;
    
       WCT_Offer__c  objCusWct= new WCT_Offer__c();
        
        objCusWct.RecordTypeId = '01240000000QLiP';
        objCusWct.WCT_status__c = 'Offer to Be Extended';
        objCusWct.WCT_Candidate__c = con.Id;
        objCusWct.WCT_Recruiter__c = con.id;
        objCusWct.WCT_Recruiter__c = con.Id;
        objCusWct.WCT_Team_Mailbox__c = 'test@deloitte.com';
        objCusWct.WCT_Type_of_Hire__c = 'Full time';
        objCusWct.OwnerId = usr.id;
        insert objCusWct;
        objCusWct.recalculateformulas();  
        WCT_Offer__c  ls =   [select id,createddate from WCT_Offer__c  where id =: objCusWct.id limit 1];
         List<BusinessHours> bhs=[select id from BusinessHours where IsDefault=true];     
         Decimal  seconds = BusinessHours.diff(Label.WCT_Default_Business_Hours_ID, objCusWct.WCT_Created_Date_Time__c, System.now())/ 1000;
             
        Decimal       hrs = Integer.valueOf(seconds / 3600);
        Decimal      min = Integer.valueOf(hrs/60);   
        
        Test.StartTest();
        Wct_OfferPendingforAnalyst objBatch = new Wct_OfferPendingforAnalyst();
        ID batchprocessid = Database.executeBatch(objBatch);
        Test.StopTest();
          
    }
}


Thanks in advance
Hi, I could not Apex test coverage to 100%. At loop nested IF was uncovered. The total coverage is 92%.

Apex Class:
 
public class Income{
    private String employeeSortOrder;
    public String currentUserId{get;set;}
    public User currentUser{get;set;}
    
    public Income() {
        currentUserId =  UserInfo.getUserId();
        currentUser = Database.query('SELECT id, Name, EmployeeNumber From User Where id=:currentUserId');
        this.employeeSortOrder = 'Name ASC';  
    }
    
    public List<Employee__c> getEmployees(){
       List<Employee__c> employees = Database.query(
           'SELECT Name, Alias__c, EmployeeCode__c, Department__c, Status__c ' +
            'FROM Employee__c ' +
            'ORDER BY ' + employeeSortOrder);
       
       for (Integer i = 0; i< employees.size(); i++){
           //Next 2 lines was not covered!
           if(currentUser.EmployeeNumber==employees[i].EmployeeCode__c) {
               employees.remove(i);
           }
        }     
            
       return employees;
    }
    
    //Sort by employee code
    public void sortByEmployeeCode() {
        if(employeeSortOrder == 'EmployeeCode__c ASC') {
            this.employeeSortOrder = 'EmployeeCode__c DESC';
        }
        else {
            this.employeeSortOrder = 'EmployeeCode__c ASC';
        }
       
    }
    
    //Sort by department
    public void sortByEmployeeDepartment() {
        if(employeeSortOrder == 'Department__c ASC') {
            this.employeeSortOrder = 'Department__c DESC';
        }
        else {
            this.employeeSortOrder = 'Department__c ASC';
        }
    }
    
    //Sort by status
    public void sortByEmployeeStatus() {
        if(employeeSortOrder == 'Status__c ASC') {
            this.employeeSortOrder = 'Status__c DESC';
        }
        else {
            this.employeeSortOrder = 'Status__c ASC';
        }
    }  
}

Test Class:
@isTest
public class incom_test{

    static testmethod void incom_test(){
        Income i = new Income();
        String result = i.currentUserId;
        User resultUser = i.currentUser;
          
        i.sortByEmployeeCode(); //Ascending
        i.sortByEmployeeCode(); //Descending       
        i.sortByEmployeeDepartment(); //Ascending
        i.sortByEmployeeDepartment(); //Descending
        i.sortByEmployeeStatus(); //Ascending
        i.sortByEmployeeStatus(); //Descending
    }
    
    static testmethod void incom_get_employee_test(){
        Income i = new Income();
        User u = i.currentUser;
        u.EmployeeNumber = '003';
        List<Employee__c> e = i.getEmployees();
        System.assertEquals(9,e.size());      
    }

}



Please help me how can I complete it to 100%?
i have an account and contact object, if i didn't select "Account lookup" in "contact", after saving the record i want to display a string value in place of "account name"  in detail page using triggers.
HI,

Im looking to reate a formula text field that will bring back either 'Yes' or 'No' depending on a date range. If the date falls between 25/15/2105 and 10/05/2016 then it should bring back Yes.

Thanks
Hi,

I need help on replacing reserved keywords with other values in my JSON response string. I have tried with replace and replaceAll methods, but​ I am getting error (System.LimitException: Regex too complicated) because of large JSON response.

Can someone help me  on this issue?​​
Hi,

I am getting this funny error when checking a Trailhead Challenge. Any ideas is this error in my 'code' or is it some kind of 'internal error' in my ORG?

"There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: [] "

I have managed to do other challenges right, but this one is bugging me => https://developer.salesforce.com/trailhead/chatter/chatter_approvals

I do have correctly named approval process in place and it writes stuff in my Chatter feed, so from my perspective the setup is working just as requested. First I had a misspelling error on the process name and 'Check Challenge' code detected that just fine. After I corrected the misspelled process name the new error message appeared...

User-added image

Thanks!
 
Hi, 

 I wrote a trigger below which is working fine now I need to get code coverage for below trigger wrote a test class its showing only 64% coverage. what is the misssing the test class 
trigger after_territory on Lead (after insert,after update) 
{
 if(checkRecursive.runOnce())
 {
 Try
 {
 Set<Id> leadIds = new Set<Id>();
 List<Territory_Lookup__c> territoryLookupList = null;
 List<Integer> gzip = new List<Integer>(); // we need a list so that we can sort it.
 Set<String> gstate = new Set<String>();
 Set<String> gcountry = new Set<String>();

 for(Lead l :   Trigger.new){
  leadIds.add(l.id);
  gstate.add(l.state);
  gcountry.add(l.country);
   if ( l.postalcode != null)
   {
   gzip.add(Integer.valueof(l.postalcode));
   }
   if ( l.postalcode == null)
   {
   gzip.add(Integer.valueof(0));
   }
 }
 
 if ( trigger.isInsert || trigger.isupdate )
 {
   territoryLookupList =  [ select id,Area__c, Country__c, Region__c, State__c, Theater__c, User__c, Zip_End__c, Zip_Start__c
                          from Territory_Lookup__c
                          where ( Country__c = :gcountry) or
                                ( Zip_Start__c <= :gzip and Zip_End__c >=:gzip) or
                                ( Country__c = :gcountry and Zip_Start__c <= :gzip and Zip_End__c >=:gzip ) or
                                ( Country__c = :gcountry and State__c = :gstate) or
                                ( Country__c = :gcountry and Zip_Start__c <= :gzip and Zip_End__c >=:gzip and State__c = :gstate )    ];
                                
  List<Lead> leds = new List<Lead>();
  
  if ( !territoryLookupList.isEmpty() )
  {
  for(lead uld : Trigger.new){                              
   lead  uleds = new lead( Id = uld.id,Territory_Lookup__c = territoryLookupList[0].id,
                           Territory_Area__c = territoryLookupList[0].Area__c,
                           Territory_Region__c = territoryLookupList[0].Region__c,
                           Territory_Theater__c = territoryLookupList[0].Theater__c);
   leds.add(uleds);
  }
    
   }  
  else
  {
   for(lead uld : Trigger.new){                              
   lead  uleds = new lead( Id = uld.id,Territory_Lookup__c = null,
                           Territory_Area__c = null,
                           Territory_Region__c = null,
                           Territory_Theater__c = null);
   leds.add(uleds);
  
   } 
  } 
   if ( leds.size() > 0) 
    {
     update leds;
     }
     
  }
}
catch (Exception e) {
List<Lead> leds = new List<Lead>();
for(lead uld : Trigger.new){ 
 lead  uleds = new lead( Id = uld.id,
                           Territory_Lookup__c = null,
                           Territory_Area__c = null,
                           Territory_Region__c = null,
                           Territory_Theater__c = null);
   leds.add(uleds);
  }
  update leds;
}  
  }
}

Test Class
 
@isTest
private class UnitTest1 {

        static testMethod void protectFields(){

                test.startTest();
                List<Lead> lstLead =   new List<Lead>{
                          new Lead(Company = 'JohnMiller', LastName = 'Mike', Status = 'Open',
                                   state='Karnataka',country='India',postalcode='5',LeadSource='Community')

                         };
        insert lstLead;

                lstLead[0].LastName = 'Mike';
                lstLead[0].Territory_Area__c = 'sudhir';
                lstLead[0].Territory_Region__c = 'sudhir';
                lstLead[0].Territory_Theater__c = 'sudhir';

                update lstLead;
                //CreateNewLead.CreateLead objcreateLead = new CreateNewLead.CreateLead();

                test.stopTest();
        }
}

Thanks
Sudhir
Hello,

I've created a custom List button on the Opportunity object that sits on the related list of the Account object.  Users go to an Account, and when they want to create a new Opportunity they click this button, which overrides the standard New button on the Opportunity related list.  When clicking the button, the user is redirected to a VF page (below), which then invokes a custom flow from a custom VF controller.  The flow works properly on its own, however, when I try to save the VF page, I get the error:

Error: No variable named "AccountWebsite" in flow

Can anyone help me figure out why I am getting this error and how to fix it?

VF Page:
<apex:page standardController="Account" tabStyle="Account" Extensions="OpptyFlowController" recordSetVar="opportunities">
    <flow:interview name="Create_Opportunity_w_Parent_Fixed" finishLocation="{!OID}">
      <apex:param name="AccountId" value="{!Account.Id}"/>
      <apex:param name="AccountWebsite" value="{!Account.Website}"/>
      <apex:param name="AccountIndustry" value="{!Account.Industry}"/>
      <apex:param name="AccountCountry" value="{!Account.BillingCountry}"/>
      <apex:param name="AccountSubIndustry" value="{!Account.Sub_Industry__c}"/>
    </flow:interview>

</apex:page>
VF Controller:
public class OpptyFlowController {

  public ApexPages.StandardSetController stdControl{get; set;}
  public OpptyFlowController(ApexPages.StandardSetController controller) {
      stdControl = controller;
  }

  public Flow.Interview.Create_Opportunity_w_Parent_Fixed OppFlow { get; set; }

    public String getOppID() {
      if (OppFlow==null) return '';
      else return OppFlow.OpportunityId;
    }

  public PageReference getOID(){
    PageReference p = new PageReference('/p/opp/SelectSearch?addTo=' + getOppID() + '&retURL=%2F' + getOppID());
    p.setRedirect(true);
  return p;
  }

}


 
Because opps is an child relationship to Account.  I am unable to use standard formula to create a field on account object that would fill in with information from a field on opportuntiy.  I was told by support that I would need to use a trigger but haven't written one before.  Can someone help with the code and I'll fill in the API fields needed?