• Adil_SFDC
  • NEWBIE
  • 35 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 31
    Questions
  • 72
    Replies
Hi I want to calculate the total response time of a REST API Transaction and display on Visualforce Page. 
 For Example if I click a button that invokes the REST API and gives me a response. I want to calculate the total time taken for the Response. 
Hi I have a SOQL query that i want to reuse by changing the where clause. I dont want to repeat the SOQL multiple times. How can this be acheived. 

Here is my query 

List<Case> groupedCases = [Select Photographer_Contact__r.Name,Scheduled_Date__c from Case 
                                where RecordType.DeveloperName In('Time_Booking', 'Media_Package', 'Photography') 
                                and Scheduled_Date__c =:dates and Photographer_Contact__r.id = :con.id];
In the above query i need results without Scheduled_Date__c =:dates 
and another query I need results without Photographer_Contact__r.id = :con.id

so that i can use respective results for further processing. 
Or is there a way i can process the resultlist 'groupedcases' not to include them .?

Hi All 
I am trying to write a utility method to get only the weekdays. Is there any easy way out. here is my code so far.  The return is in the form "09/16/2014 - Tue". I just need the Date. 

public class Utility_WorkingDays {
	
	public  List<String> getHeadDates(){
        List<String> formattedDates = new List<String>();
		List<DateTime> headDates = new List<DateTime>();
		DateTime currentDate = DateTime.now();
		//Date currentDate = currentDateTime.Date;
		for (Integer idx=0; idx<28; idx++){
        	headDates.add(currentDate+idx);
	    } 
	    for(DateTime dt: headDates){
	    	String formatDatewithDay = dt.format('MM/dd/yyyy - E');
	    	formattedDates.add(formatDatewithDay);
    	   	for(Integer i = 0; i< formattedDates.size();i++){
	        	String weekend = formattedDates.get(i);
	        	system.debug('here :'+weekend);
	        	if(weekend.contains('Sun') || weekend.contains('Sat')){
	        		
	        		formattedDates.remove(i);
	        	}
        }
	      
	    }
	    system.debug('dates:'+formattedDates);
		return formattedDates;
	}
}




Hi I need to get the selected value in my param that needs to be passed to the controller. right now my apex parameter value is hard coded to 06 any help

<apex:sectionHeader title="Field Researcher Schedule for Region" />

            <apex:selectList value="{!contactSalesRegion}" size="1" multiselect="false">
                <b>Field Researcher Schedule for Region</b>
                <apex:selectOptions value="{!SalesRegionsCoveredValues}"></apex:selectOptions>
                <apex:actionSupport event="onchange" action="{!salesRegionCoveredFilter}" reRender="dataBlock">
                    <apex:param name="salesRegionId" assignTo="{!salesRegionId}" <strong><em><u>value="06"</u>></em></strong></apex:param>
                </apex:actionSupport>
            </apex:selectList>
            
            <apex:outputPanel id="dataBlock">
            <apex:pageBlock >
					 
        
                        <b>Scheduled Date</b>
                   
                <table class="list" border="0" cellpadding="0" cellspacing="0">
public class PhotoSchedulerController {

    public String salesRegionId { get; set; }
    public String ContactSalesRegion {get;set;}
    public List<Contact> contactsToDisplay {get;set;}
        
    public void salesRegionCoveredFilter() {
    	
        system.debug('sales Region ID:'+salesRegionId);// HERE I NEED  SELECTED VALUES FROM PICK LIST
       // getDataRows();
    }
    

    public  List<SelectOption> getSalesRegionsCoveredValues() {
       List<SelectOption> options = new List<SelectOption>();
       Schema.DescribeFieldResult salesRegion = Contact.Sales_Regions_Covered__c.getDescribe();
       List<Schema.PicklistEntry> salesRegions = salesRegion.getPicklistValues();
       for(Schema.Picklistentry entry : salesRegions){
            options.add(new SelectOption(entry.getLabel(),entry.getValue()));
        }
        return options;
    }



Hi Experts,
I am trying to render a visualforce Page with the change in picklist values. The data I would like to render is the contact names in  a table. which changes depending on the sales Region i choose. 

Here is my page and controller so far. Any help is appreciated.
<apex:page controller="PhotoSchedulerController" tabstyle="Report" sidebar="false">
<apex:form >
<apex:outputPanel id="dataBlocks" >
<apex:sectionHeader title="Field Researcher Schedule for Region"/>

<apex:selectList value="{!contactSalesRegion}" size="1" multiselect="false">
 <b>Field Researcher Schedule for Region</b><apex:selectOptions value="{!SalesRegionsCoveredValues}" > </apex:selectOptions>
<apex:actionSupport event="onchange" action="{!salesRegionCoveredFilter}" reRender="dataBlock" > 
<apex:param name="salesRegionId" assignTo="{!salesRegionId}" value="{!SalesRegionsCoveredValues}"></apex:param>  
</apex:actionSupport> 
</apex:selectList>

<apex:pageBlock >
 
<table class="list" border="0" cellpadding="0" cellspacing="0"  id="dataBlock" >

  <tr>
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;

     <b>Scheduled Date</b>
 
  </tr>
    <tr>
      
      <td>
      </td>
      <apex:repeat value="{!headDays}" var="days">
        <th style="background-color:#00BFFF;">
            {!days}
        </th>
    </apex:repeat>
    </tr>
   
    <tr class="headerRow  ">
      <th style="background-color:#00BFFF;">Photographer: Full Name</th>
      
      <apex:repeat value="{!headDates}" var="heading">
        <th style="background-color:#00BFFF;" class="headerRow ">
           {!heading}
        </th>
      </apex:repeat>
    </tr>
    <apex:repeat value="{!DataRows}" var="dRow">
       <apex:repeat value="{!dRow.contacts}" var="photo">
           <tr>
               <td style="background-color:#d4dadc;">
                  <a href="https://apartments--pre.cs20.my.salesforce.com/{!photo.Id}"> {!photo.Name} </a>
               </td>
            
            <apex:repeat value="{!dRow.cases}" var="count">
           
                <td> 
                 {!count.casenumber}
                </td>
              
            </apex:repeat>

            </tr>
         </apex:repeat>
         
    </apex:repeat>
  </table>
  </apex:pageBlock>
  </apex:outputPanel>
    </apex:form> 
</apex:page>
public class PhotoSchedulerController {

    public String salesRegionId { get; set; }
    public String ContactSalesRegion {get;set;}

    public PageReference salesRegionCoveredFilter() {
    	String contacts =  [Select Id,Name,Sales_Regions_Covered__c from Contact where Sales_Regions_Covered__c= '03'].Sales_Regions_Covered__c;
    	         system.debug('sales region:'+contacts);
    	
        return null;
    }

    public  List<SelectOption> getSalesRegionsCoveredValues() {
       List<SelectOption> options = new List<SelectOption>();
        Schema.DescribeFieldResult salesRegion = Contact.Sales_Regions_Covered__c.getDescribe();
        List<Schema.PicklistEntry> salesRegions = salesRegion.getPicklistValues();
        for(Schema.Picklistentry entry : salesRegions){
            options.add(new SelectOption(entry.getLabel(),entry.getValue()));
        }
        return options;
    } 
    
    public List<String> getHeadDays() {
        List<String> formattedDays = new List<String>();
        List<DateTime> days = new List<DateTime>();
        DateTime currentDay = DateTime.now();
        for (Integer idx=0; idx<28; idx++){
            days.add(currentDay+idx);
        system.debug('DAYS :'+days);
        } 
        for(DateTime dt: days){
            String formattedDay = dt.format('E');
            formattedDays.add(formattedDay);
        }
        return formattedDays;
    }
    
    public List<String> getHeadDates(){
        List<String> formattedDates = new List<String>();
        List<Date> dates = new List<Date>();
        Date currentDate = system.today();
        for (Integer idx=0; idx<28; idx++){
            dates.add(currentDate+idx);
        }
       
        for(Date dt: dates){
            String formattedDate = dt.format();
            formattedDates.add(formattedDate);
           
        }
        return formattedDates;
        }
        
    // retrieves the row wrapper containing the wrapped case headings
    public List<photographerRow> getDataRows(){
        List<String> scheduledDates = new List<String>();
        photographerRow pRow = new photographerRow();
        List<photographerRow> dataRows = new List<photographerRow>();
        for(Contact con : getContacts()){
            pRow.photographer = con.Name;
            pRow.photographerId = con.Id;
            pRow.contacts.add(con);
        }
        for (Integer idx=28; idx>0; idx--) {
            pRow.subtotals.add(idx);
        }
        
        for(Case c : getCaseInfo()){
            pRow.caseNumber = c.caseNumber;
            pRow.cases.add(c);
        }
    
        dataRows.add(pRow);
        return dataRows;
    }
    
    public class photographerRow{
        public String photographer {get; set;}
        public String photographerId {get;set;}
        public String caseNumber{get;set;}
        public List<Contact> contacts {get;set;}
        public List<Case> cases {get;set;}
        public List<Integer> subtotals {get; set;}
        public List<Integer> counts {get; set;}
        // constructor
        public PhotographerRow(){
            contacts = new List<Contact>();
            subtotals=new List<Integer>();
            counts=new List<Integer>();
            cases = new List <Case>();
        }
    }
    
    
    public List<Contact> getContacts(){
        List<Contact>contacts =  [Select Id,Name,Sales_Regions_Covered__c from Contact ];
        return contacts;
    }
    

    
    public List<Case> getCaseInfo(){
        List<String> contactsList = new List<String>();
        List<String> formattedDatesList = new List<String>();
        for(Contact c :  getContacts()){
                        contactsList.add(c.Name);
        }
        List<Date> dates = new List<Date>();
        Date currentDate = system.today();
        for (Integer idx=0; idx<28; idx++){
            dates.add(currentDate+idx);
        }
        system.debug('Dates List :'+dates);
        system.debug('Contact LIst :'+contactsList);
        
        List<Case> cases = [Select id,CaseNumber,Scheduled_Date__c ,Account.Owner.Name,Photographer_Contact__r.Name from Case where RecordType.DeveloperName In('Time_Booking','Media_Package','Photography') 
                                                        and Scheduled_Date__c=:dates];
        system.debug('case queried:'+cases);
        return cases;   
    }   
    
  


    /* public Integer getCaseCount(){
        Integer caseCount;
        List<AggregateResult> groupedCases = [Select count(casenumber),Scheduled_Date__c, Photographer_Contact__r.Name from Case where RecordType.DeveloperName In('Time_Booking', 'Media_Package', 'Photography') and Scheduled_Date__c!=null group by Photographer_Contact__r.Name,Scheduled_Date__c];
        for (AggregateResult ar : groupedCases)  {
                caseCount = Integer.valueOf(ar.get('expr0'));
        }
    return caseCount;
    }*/
}
Thanks for the expert advice. 
Adil

Hi All 

I would like to replicate the attached report in visualforce . 
I want the column headers  to hold the weekdays as shown .
The data in the columns is from Case Object. 0's and 1's represent the number of case records on that particualr day. 
Is there any easy way out.Report to be transformed to Visualforce

Check box to Select All on VF Page. I am trying this but no go

 

<apex:page standardController="Listing__c"   extensions="TFNController" id="myPage" showHeader="false">
  
 
       <apex:pageMessages id="messages"/> 
 <apex:form id="myform" >

<apex:PageBlock title="TFN Provisioning for Listing :" />
<apex:PageBlock id="pageload">
  <apex:PageBlockSection columns="1" id="theSection" > 
<apex:outputPanel style="vertical-align:top" >
  <table border="1" class="list" width="100%" cellpadding="0" cellspacing="0" id="aheadertable" >
                 <tr >  
                
                  <td width="2%"  style="font-weight:bold;text-align:center;vertical-align:bottom" rowspan='2'><b>
                    <apex:inputCheckbox id="SelectAll"   onclick="selectAll()" /></b></td>
</tr>
  </table>  
            </apex:outputPanel> 
           <apex:outputPanel style="vertical-align:top" id="test">
      <apex:repeat var="TFNAffiliate" value="{!TFNVFResults}" id="TFNAffiliateId"> 
                     <table border="0" width="100%" class="list" cellpadding="0" cellspacing="0" id="atable" >
                        <tr class="row" style="persist: location;">
                            <td width="2%" style="text-align:center" >
                             <apex:inputCheckbox id="select" value="{!TFNAffiliate.selected}" styleclass="select" /> 
                           </td>
 </table> 
                   </apex:repeat>   
                   </apex:outputPanel>    
                  </apex:PageBlockSection> 
                      </apex:PageBlock>
                           </apex:form>
<script>
function selectAll()
 {
   // var listSize = {!TFNVFResults.size};
   // alert(!TFNVFResults.size);
   // var i;
     var select;
  var selectall =  document.getElementById('{!$Component.myPage.myform.pageload.theSection.selectAll}');


  //if (selectall.checked){
  alert(selectall.value);
   
 // }
for (i = 0; i < listSize; i++) {
          
      select = document.getElementById('myPage:myform:pageload:theSection:TFNAffiliateId:'+i+':select}');
      }
 alert('test'+select.value);
 }
 </script>
   
</apex:page>

 

All

 

Here is my query

 

orderHistListRec33 = [Select Name,Account__c,Order_Status__c, Case_Number__c, Product_Description__r.Is_Package__c, Product_Description__r.Name,CreatedDate
From Order_History__c order by createdDate dsc ];

 

I get 

 

 

List is 

 

OrderHistoryNumber (Name): 123    Product_Description__r.Name:Branding    CreatdeDate : 6/25/13

OrderHistoryNumber(Name) : 124    Product_Description__r.Name:CHAT    CreatdeDate : 6/25/13

OrderHistoryNumber (Name): 125    Product_Description__r.Name:Branding   CreatdeDate : 6/22/13

OrderHistoryNumber(Name) : 126     Product_Description__r.Name:CHAT    CreatdeDate : 6/22/13

 

I want to eleiminate duplicate Product_Description__r.Name and get most recent i.e. 

 

 

OrderHistoryNumber (Name): 123    Product_Description__r.Name:Branding    CreatdeDate : 6/25/13

OrderHistoryNumber(Name) : 124    Product_Description__r.Name:CHAT    CreatdeDate : 6/25/13

 

how do i modify my query .

Hi All 

 

I have a SOQL Query which returns me following results of Product in  a LIST

Select Account__c,Order_Status__c, Case_Number__c, Product_Description__r.Is_Package__c, Product_Description__r.Name
From Order_History__c

 

1. Name : Branding    Last Modified: 06/28/13

2.  Name : AHL   Last Modified: 06/2/13

3. Name : CHAT    Last Modified: 06/28/13

4. Name : Branding    Last Modified: 06/29/13

5.Name: CHAT     Last Modified: 06/27/13

 


In the above list i have two similar product names i just want to get most recent modified Product Name. I want my list to look like 

 

 

1.  Name : AHL   Last Modified: 06/2/13

2. Name : CHAT    Last Modified: 06/28/13

3. Name : Branding    Last Modified: 06/29/13

 

 

hOW DO I MODIFY MY QUERY TO GET THE ABOVE RESULT

Hi  All

 

I have a field on Case Object " Last Contacted"

This field needs to be updated with the Last Modified Date of the Activity History of the Case. 

A trigger should fire whenever  a new activity history is created or an exisiting activity history is last modified and update the field on case

 

Thanks in advance

I have VF page and I am using iframe in VF Page 

<apex:tab label="Fulfillment" >
<iframe src="\apex\DXGAccountFulfillment?id={!account.id}" width="100%" height="1500px"></iframe>

</apex:tab>

 

the VF PAge DXGAccountFulfillment has header and sidebar. I need to hide them for few profiles. I dont want to create 2 different VF Pages just to hide header.

Is there a way out to hide header based on profile. 

 

Thanks

 

Hi All 

 

I have a requirement to insert 7 records once.

 

I have 7 Record Types. If I create 1 Record with 1 Record Type my trigger to should insert other 6 records with 6 different record types.

I have a Lead Object and the lead has child object called "Home_Service_c"

Home service object has 7 record types.

 

Thanks in Advance

 

Hi  I have the following trigger to write 

 

Write a trigger on the Lead object that populates a custom field on Lead, called Lead.Territory__c, with the ZipTerr__c.Territory__c that matches Lead.PostalCode to ZipTerr__c.Zip__c. 

 

Below is the ZipTerr object (table)

ZipTerr__c

Zip__c

Territory__c

94305

201

94261

201

75093

101

75248

101

 

 

Any help please

 Hi All 

My requirement is to call a REST API  which gives an XML Response. 

I have to parse that XML and display on VF Page. Is there any example how can I go about it. 

 My requirement is to call a REST API  which gives an XML Response. 

I have to parse that XML and display on VF Page. Is there any example how can I go about it. 

Here is my code and test method. 

 

It has to increase from 43 to 75.

the dosearch() and sendemailcreatetask() methods are not covered.

Any idea how to cover those

 

 

public with sharing class ContactiCenteraIntegration
{
public String documentSearchString {get; set;}
public Boolean isInDocument {get;set;}

public List<SelectOption> productList {get; set;}
public String productVal {get; set;}
public String sortField {get; set;}
public String previousSortField {get; set;}
public string docIDString{get;set;} 
public List<String> docIdsList = new List<String>();
public List<SelectOption> solutionList {get; set;}
public String solutionVal {get; set;}

public String apiServerURL {get; set;}
public String apiServerSession {get; set;}
public String description {get; set;} 
//public list<HelpText__c> custom {get; set;}

public List<Document> documentList {get; set;}
public string selecttitle {get; set;}
public Boolean showPrevious {get; set;}
public Boolean showNext {get; set;}
public Integer firstRecPosition {get; set;}


private String email {get; set;}
private String resBody {get; set;}

private Contact c;
public Integer pos {get; set;}
public Integer rowLimit {get; set;}
public String isDynamic {get; set;}
public String iscustomized {get; set;}
private String tokenVal = '';
private String testVar = '';

public ContactiCenteraIntegration(ApexPages.StandardController sc)
{

c = (Contact)sc.getRecord();
documentList = null;
c = [select id, name, email from Contact where id = :c.id];

showPrevious = showNext = false;
rowLimit = 20;
documentSearchString = ''; 

}

public void search()
{
if(documentList != null)
documentList.clear();
HttpRequest req = new HttpRequest();
//379 QTM
//364 TR 
//12 Apps
//326 
String fedId = [SELECT FederationIdentifier FROM User WHERE Id =: UserInfo.getUserId()].FederationIdentifier;
system.debug('fedid:::'+fedId);
String endPoint = 'http://api.icentera.com/v1sandbox/AuthenticationService.svc/json/authenticateSFSession?siteid=12&username=clesinski@icentera.com&sessionid='+apiServerSession+'&instanceUrl='+apiServerURL;//https://icentera-4.na2.visual.force.com/services/Soap/u/8.0/00D300000000PEv';//'http://api.icentera.com/v1/AuthenticationService.svc/json/authenticateSFSession?siteid=14&uid=10940&sessionid='+UserInfo.getSessionId()+'&instanceUrl=https://icentera-4.na2.visual.force.com/services/Soap/u/8.0/00D300000000PEv';//https://login.salesforce.com/services/Soap/u/23.0';//'http://api.icentera.com/iCenteraService/AuthenticationService.svc/json/authenticate?siteid='+UserInfo.getOrganizationId()+'&uid='+UserInfo.getUserId()+'&sessionid='+UserInfo.getSessionId()+'&instanceUrl=https://na2.salesforce.com/';//'https://api.icentera.com/iCenteraService/TestService.svc/json/AuthenticateSFSession?siteid='+UserInfo.getOrganizationId()+'&uid='+UserInfo.getUserId()+'&sessionid='+UserInfo.getSessionId(); 
req.setMethod('GET');
HTTPResponse res;

// system.debug('API URL is :::: '+apiServerURL);

req.setEndpoint(endPoint);
req.setTimeout(60000);

Http http = new Http();
if(testVar == '')
{
res = http.send(req);
resBody = res.getBody();
}
else
resBody = '{"d":"c577d54db33f416ab2e28b2ae00098b8"}';

JSONParser parser = JSON.createParser(resBody);
tokenVal = '';
while ( parser != null && parser.nextToken() != null) 
{
system.debug('PRINT'+parser.getText());
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'd')) 

{

if (parser.nextToken() != null ) {
tokenVal = parser.getText();

// break;
}

}
} 
if (tokenVal != '') {
req = new HttpRequest();
endPoint = 'http://api.icentera.com/v1sandbox/TestService.svc/json/searchDocuments?token='+tokenVal+'&search='+documentSearchString+'&sensitivity=1&page=1&productIds=&solutionIds=';
system.debug('XXXX'+documentSearchString);
req.setMethod('GET');
req.setEndpoint(endPoint);
req.setTimeout(60000);

http = new Http();
if(testVar == '')
{
res = http.send(req);
resBody = res.getBody();
}
else
resBody = '{"d":{"__type":"DocumentSearchResult:#iCenteraServices","Documents":[{"__type":"SimpleDocument:#iCenteraServices","CustomerReady":true,"Description":null,"FileType":"xls","Id":1042,"InternalOnly":false,"NDARequired":false,"PartnerReady":true,"Rating":4,"Title":"ROI Worksheet - REVENUE VERSION","URL":""}]}}';

parser = JSON.createParser(resBody);

system.debug('callingcreate');
createDocuments(parser);
sortField = previousSortField = null;
} 
else 
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Unable to create a Session ')); 

}
public List<Document> defaultSortdocIds(List<Document> OdocList ){
List<String> docId = new List<String>();
List<String> finaldocId = new List<String>();
List<Document> tempdoc = new List<Document>(); 
for(Document d : OdocList){

docId.add(d.id);
}
docId.sort();

for(Integer i=docId.size()-1;i>=0;i--){

finaldocId.add(docId.get(i));
}



for(String s : finaldocId){
for(Document d : OdocList){

if(d.id==s){
tempdoc.add(d);
}

}

}
return tempdoc;
}

public void createDocuments(JSONParser parser)
{
system.debug('1. Printing debug log'); 

documentList = new List<Document>();

// system.debug('rrrr'+documentList.size());
Document doc = new Document();
Integer position = 0;
while (parser.nextToken() != null) 
{
system.debug('1.1 Printing debug log inside while loop'); 
if (parser.getCurrentToken() == JSONToken.START_OBJECT || parser.getCurrentToken() ==JSONToken.END_OBJECT) 
{ 
if(doc.title != null)// && doc.url != null && doc.rating != null && doc.filetype != null && doc.id != null && doc.description != null)
{
doc.position = position;
position++;
documentList.add(doc);

doc = new Document();
} 

}
if (parser.getCurrentToken() == JSONToken.FIELD_NAME) 
{
system.debug('1.2 Printing debug log'); 
if(parser.getText() == 'title')
{
parser.nextToken();
doc.title = parser.getText();
docIdsList.add(doc.title);
}
if(parser.getText() == 'id')
{
parser.nextToken();
doc.id = parser.getText();
// docIdsList.add(doc.id);
}
if(parser.getText() == 'description')
{
parser.nextToken();
doc.description = parser.getText();
}
if(parser.getText() == 'url')
{
parser.nextToken();
doc.url = parser.getText();
// system.debug('URL is '+doc.URL);
}
if(parser.getText() == 'filetype')
{
parser.nextToken();
doc.fileType = parser.getText();
}
if(parser.getText() == 'rating')
{
parser.nextToken();
doc.rating = parser.getText(); 
}
system.debug('3. Printing debug log'); 
if(parser.getText() == 'lastupdated')
{
parser.nextToken();
doc.lastupdated = parser.getText(); 
doc.st = ((doc.lastupdated.split('\\.',2).get(0)).split('T',2)).get(0)+' '+((doc.lastupdated.split('\\.',2).get(0)).split('T',2)).get(1); 
doc.st = doc.st.substring(0, doc.st.indexOf(' '));
system.debug('2. Printing debug log'); 
system.debug('Doc Date:'+doc.st);

}

if(parser.getText() == 'totalViews')
{
parser.nextToken();
doc.internalOnly = Boolean.valueOf(parser.getText()); 
}

/* if(doc.title != null)// && doc.url != null && doc.rating != null && doc.filetype != null && doc.id != null && doc.description != null)
{
doc.position = position;
position++;
documentList.add(doc);

doc = new Document();
}*/

}
}
if(documentList!=null){
sortField = 'st';
previousSortField='st';
dosort();
system.debug('mmmm'+documentList.size());

// documentList = defaultSortdocIds(documentList);
system.debug('DDDDD'+documentList.size());
}
 


if(documentList.isEmpty())
{

documentList = null;
showPrevious = showNext = false;

ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'No results were found for the search string \''+documentSearchString+'\'.'));
}
else if(documentList.size() <= rowLimit)
{
showPrevious = showNext = false;
}
else 
{ 
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Document List '+rowLimit+' of '+documentList.size())); 
showNext = true;
showPrevious = false ;

}
firstRecPosition = 0;
}




public void populateDocString(){

String title='';
Integer numberOfSelected=0;
if(documentList!=null && documentList.size()>0)
{
for(Document d: documentList)
{


if(d.isChecked)
{
numberOfSelected++;
if( numberOfSelected==1)
title = d.title;

} 
}
}

if ( numberOfSelected==1)
{

docIDString = title;
}
else if ( numberOfSelected>0)
{

numberOfSelected=numberOfSelected-1;
docIDString = title+' '+numberOfSelected+' other(s)';
}else 
docIDString = null;


}




/*public String getdocIDString(){
String title='';
if(documentList!=null && documentList.size()>0)
{
for(Document d: documentList)
{
if(d.isChecked)
{
title = d.title;
break;

} 
}
}
return title;
}*/

public void setdocIDString(String s){
docIDString =s ;

}

public void showNextRecs()

{
if((firstRecPosition + rowLimit) <= documentList.size())
{

firstRecPosition = firstRecPosition + rowLimit;
if(firstRecPosition!=0)
showPrevious = true;


if(firstRecPosition + rowLimit >= documentList.size())
showNext = false;
}
else
{
showNext = false;
showPrevious = true;
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Next '+rowLimit+' of '+documentList.size())); 
}
public void showPreviousRecs()
{
if((firstRecPosition - rowLimit) <= 0)
{
firstRecPosition = firstRecPosition - rowLimit;
showNext = true;
showPrevious = false;

}
else if((firstRecPosition - rowLimit) >= 0)
{
firstRecPosition = firstRecPosition - rowLimit;
showNext = true;

}
else
{
showPrevious = false;
showNext = true;
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Size '+rowLimit+' of '+documentList.size())); 
}
 
public void sendMailAndCreateTask(List<Document> dList)
{
List<Task> taskList = new List<Task>();

String endPoint;
HTTPResponse res;
HttpRequest req = new HttpRequest();


Http http = new Http();
String customizedEmailText = '';
String customizedEmailSub = '';

Contact_Email__c[] ce = [select Subject__c,description__c from Contact_Email__c where user__c = :UserInfo.getUserId()];
if( ce.size() >0 &&ce[0].description__c != null)
{

}


String docIdsSelected ;
if(dList!=null &&dList.size()>0) 
docIdsSelected = dList[0].id;
if(dList!=null && dList.size()>1)
for(Integer i=1;i<dList.size();i++){
docIdsSelected = docIdsSelected + ','+dList[i].id;
system.debug('Docdocdoc'+ docIdsSelected );
}
/*List< Contact_Email__c> lstcon = new List<Contact_Email__c>();
Contact_Email__c cont = new Contact_Email__c();
//cont.subject__c= selecttitle;
ce.add(cont);*/
Integer ra=dList.size() - 1;
// docIdString=dList[0].title;
if(dList!=null &&dList.size()>1)

{
selecttitle = dList[0].title+' '+'and'+' '+ra+' '+'other(s)';
selecttitle = EncodingUtil.UrlEncode(selecttitle,'UTF-8'); 
system.debug('yyy'+selecttitle);
}
if(dList!=null &&dList.size()==1) 
selecttitle = EncodingUtil.UrlEncode(dList[0].title,'UTF-8'); 
system.debug('rrrr'+selecttitle);




// if(ce.size()>0){iscustomized
if(isDynamic == 'true')
endPoint = 'http://api.icentera.com/v1sandbox/TestService.svc/json/EmailDocuments?token='+tokenVal+'&docids='+docIdsSelected+'&recipient='+c.Email+'&subject='+selecttitle+'&sfdccontactid='+c.id+'&isDynamic=true'+'&body=';
if(isDynamic == 'true')
endPoint = 'http://api.icentera.com/v1sandbox/TestService.svc/json/EmailDocuments?token='+tokenVal+'&docids='+docIdsSelected+'&recipient='+c.Email+'&subject='+customizedEmailSub+'&sfdccontactid='+c.id+'&isDynamic=true'+'&body='+customizedEmailText;
system.debug('XXXX'+endpoint);
if(isDynamic == 'false')
endPoint = 'http://api.icentera.com/v1sandbox/TestService.svc/json/EmailDocuments?token='+tokenVal+'&docids='+docIdsSelected+'&recipient='+c.Email+'&subject='+customizedEmailSub+'&sfdccontactid='+c.id+'&body='+customizedEmailText;
if(isDynamic == 'false') 
endPoint = 'http://api.icentera.com/v1sandbox/TestService.svc/json/EmailDocuments?token='+tokenVal+'&docids='+docIdsSelected+'&recipient='+c.Email+'&subject='+selecttitle+'&sfdccontactid='+c.id+'&body='+customizedEmailText;

// }



boolean dListcountertrack=false;
for(Document d: dList)
{

if(d==dList[0])
dListcountertrack=true;
else
dListcountertrack=false;


req.setMethod('GET');
req.setTimeout(60000);

req.setEndpoint(endPoint);
system.debug('eee'+endpoint);

Task t = new Task();
t.WhoId = c.id; 
t.Subject = 'iCentera Dynamic Email sent for '+d.title;
t.status = 'Completed';
t.type = 'Email';
String comments = d.title+'\n\n';
comments += 'Please download and save the following linked file:\n';
comments += '\nTitle:'+d.title;
comments += '\nFormat:'+d.filetype;
comments += '\nDescription:'+d.description;

t.description = comments;
taskList.add(t);

if(testVar == '' && dListcountertrack)
{
res = http.send(req);
JSONParser parser = JSON.createParser(res.getBody());
while (parser.nextToken() != null) 
{
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'd')) 
{
parser.nextToken();
if(parser.getText() == 'true')
{
// taskList.add(t);

ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email sent successfully for the selected documents.'));// \''+d.title+'\'.'));
}
else
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email could not be sent.')); 
}
}
} 

}

}
insert taskList;
}

public void doSort()
{
List<Document> docList = new List<Document>();
List<Document> tempDocList = new List<Document>();
List<Integer> positionList = new List<Integer>();
Set<Integer> positionSet = new Set<Integer>();
List<String> tempList = new List<String>();
String order = 'asc';


if(previousSortField == sortField)
{
order = 'desc';
previousSortField = null; 
}
else
previousSortField = sortField;
for(Document d: documentList)
{
if(sortField == 'Title')
tempList.add(d.title.toLowerCase());
else if(sortField == 'fileType')
tempList.add(d.fileType.toLowerCase());
else
tempList.add(d.st);
tempDocList.add(d);
}
tempList.sort();


if(order == 'desc')
{
List<String> tList = tempList.clone();
tempList.clear();
for(Integer i=tList.size() - 1; i>=0; i--)
tempList.add(tList[i]);
}
Integer z = 0;
for(String s: tempList)
{
//system.debug('\nTTTTTT :: '+s+ ' ===== '+z);
z++;
}

//Integer remPos;
for(String s: tempList)
{
for(Integer i=0; i<= tempDocList.size(); i++)
{
system.debug('qqqq'+tempdoclist);
if((tempDocList[i].title.equalsIgnoreCase(s) || tempDocList[i].fileType.equalsIgnoreCase(s)||tempDocList[i].st.equalsIgnoreCase(s)) && !positionSet.contains(tempDocList[i].position))

{
positionList.add(tempDocList[i].position);
positionSet.add(tempDocList[i].position);
break;
}
}
}

documentList.clear();
for(Integer i: positionList)
{
for(Document d: tempDocList)
{
if(d.position == i)
{
documentList.add(d);
break;
} 
}
}
firstRecPosition = 0;
showPrevious = showNext = true;
}

public class Document
{
public String type {get; set;}
public String description {get; set;}
public String fileType {get; set;}
public String id {get; set;}
public String rating {get; set;}
public String title {get; set;}
public String url {get; set;}
public Integer position {get; set;}
public Boolean internalOnly {get;set;}
public Boolean isChecked {get; set;}
public string lastupdated {get; set;}
public String st {get; set;}

public Document()
{
type = null;
description = null;
fileType = null;
id = null;
rating = null;
title = null;
url = null;
internalOnly = false;
isChecked = false;
lastupdated = null;
// st = null;
}

}

public void sendEmail()
{
List<Document> tempDocumentList = new List<Document>();
for(Document d: documentList)
{
if(d.isChecked)
{
// ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,d.title+' =========== '+d.isChecked));
//System.debug(d.title+' =========== '+d.isChecked);
tempDocumentList.add(d);
//System.debug('TTTt'+tempDocumentList );
}
} 
sendMailAndCreateTask(tempDocumentList);

contact_email__c[] ceList = [select id,Subject__c, description__c, user__c from contact_email__c where user__c = :UserInfo.getUserId()];
if(celist.size()>0)
delete ceList;
}

public void reset()
{
if(documentList != null)
documentList = null;

documentSearchString = null;
showPrevious = showNext = false;
}
public class custom{

}

public static testMethod void testICentera()
{
PageReference pageRef = Page.ContactiCenteraIntegration;
Test.setCurrentPage(pageRef);
Contact ct = new Contact(Email='imohamme@calliduscloud.com',lastname='Ahmed');
insert ct;
Contact c = [select id from Contact where id = :ct.id];
ApexPages.StandardController sc = new ApexPages.standardController(c);
ContactiCenteraIntegration controller = new ContactiCenteraIntegration(sc);
controller.pos = 0;
controller.testVar = 'in Test';
controller.documentSearchString = '';

// controller.search();
controller.documentSearchString = 'test';

//controller.search();
//controller.showNextRecs();
// controller.showPreviousRecs();
ContactiCenteraIntegration.Document d = new ContactiCenteraIntegration.Document();
controller.sortField = 'Title';
controller.previousSortField = 'lastupdated';
//controller.doSort();
controller.sortField = 'Title';
controller.previousSortField = 'Title';
// controller.doSort();
controller.documentList= new List<Document>();
d.title = 'iCentera';
d.fileType = 'xls';
d.position = 0;
d.st= '2012-07-09';

controller.documentList.add(d);
d = new ContactiCenteraIntegration.Document();
d.title = 'iCentera';
d.fileType = 'xls';
d.position = 1;
d.st= '2012-07-08';
controller.documentList.add(d);
d = new ContactiCenteraIntegration.Document();
d.title = 'iCentera';
d.fileType = 'pdf';
d.position = 2;
d.st= '2011-07-09';
controller.documentList.add(d);

//controller.sendMailAndCreateTask(controller.documentList);
controller.sortField = 'st';
controller.previousSortField = 'st';
controller.doSort();

controller.showNextRecs();
controller.showPreviousRecs();
controller.sendEmail();

}
}

 

public void sendMailAndCreateTask(List<Document> dList)
    {
        List<Task> taskList = new List<Task>();
        
        String endPoint;
        HTTPResponse res;
 
        HttpRequest req = new HttpRequest();
        
  
        Http http = new Http();
        String customizedEmailText = '';
          String customizedEmailSub = '';
  
       Contact_Email__c[]  ce = [select Subject__c,description__c from Contact_Email__c where user__c = :UserInfo.getUserId()];
        if(ce.size() >0 && ce[0].description__c != null)
        {
          customizedEmailText = EncodingUtil.UrlEncode(ce[0].description__c,'UTF-8');
           customizedEmailSub = EncodingUtil.UrlEncode(ce[0].Subject__c,'UTF-8');
          
        }
        
       
      Integer ra=dList.size() - 1;
              //  docIdString=dList[0].title;
        if(dList!=null &&dList.size()>0) {
    selecttitle = dList[0].title+' '+'and'+' '+ra+' '+'others';
     selecttitle = EncodingUtil.UrlEncode(selecttitle,'UTF-8'); 
     }
     
             if(dList!=null &&dList.size()==1) 
     selecttitle = EncodingUtil.UrlEncode(dList[0].title,'UTF-8'); 
           
           String docIdsSelected ;
       if(dList!=null &&dList.size()>0) 
        docIdsSelected = dList[0].id;
 
       if(dList!=null && dList.size()>1)
        for(Integer i=1;i<dList.size();i++){
        docIdsSelected = docIdsSelected + ','+dList[i].id;
        system.debug('Docdocdoc'+ docIdsSelected );
        }
    
        if(isDynamic == 'true'&&ce[0].Subject__c==null  ) ( ERROR)
         
     else  if(isDynamic == 'true'&&ce[0].Subject__c!=null)
 
           
            else if(isDynamic == 'false'&&ce[0].Subject__c!=null)
               
               
               else  
               
               
               
                   system.debug('XXXX'+endpoint);
                   
        /*if(testVar == '')
            {
                res = http.send(req);
                JSONParser parser = JSON.createParser(res.getBody());
                while (parser.nextToken() != null) 
                {
                    if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'd')) 
                    {
                        parser.nextToken();
                        if(parser.getText() == 'true')
                        {
                            taskList.add(t);
                            
                            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email sent successfully for the selected documents.'));// \''+d.title+'\'.'));
                        }
                        else
                        {
                            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email could not be sent.'));                        
                        }
                    }
                }        
                    
            }*/
            
            boolean dListcountertrack=false;
        for(Document d: dList)
        {
      
         if(d==dList[0])
         dListcountertrack=true;
         else
         dListcountertrack=false;
          
        // docIdsSelected = d.Id;
     //  if(isDynamic == 'true')
         
               
          //  else
  //   system.debug('eeeee'+dList);
            req.setMethod('GET');
            req.setTimeout(60000);
    
            req.setEndpoint(endPoint);
   
            Task t = new Task();
            t.WhoId = c.id
            t.Subject = 'iCentera Dynamic Email sent for '+d.title;
            t.status = 'Completed';
            t.type = 'Email';
            String comments = d.title+'\n\n';
            comments += 'Please download and save the following linked file:\n';
            comments += '\nTitle:'+d.title;
            comments += '\nFormat:'+d.filetype;
            comments += '\nDescription:'+d.description;
    
            t.description = comments;
            taskList.add(t);
            
           if(testVar == '' && dListcountertrack)
            {
                res = http.send(req);
                JSONParser parser = JSON.createParser(res.getBody());
                while (parser.nextToken() != null) 
                {
                    if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'd')) 
                    {
                        parser.nextToken();
                        if(parser.getText() == 'true')
                        {
                           // taskList.add(t);
                            
                            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email sent successfully for the selected documents.'));// \''+d.title+'\'.'));
                        }
                        else
                        {
                            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email could not be sent.'));                        
                        }
                    }
                }        
                    
            }
                
        }
 
        insert taskList;
    }

Hi All 

 

I am trying to get documents from an external website in a list  in the descending order of last updated field. 

 

Now the document might have been updated many times since the date it is created. So my list is displaying the documents same number of times, I want it to be displayed  only once w.r.t to Id How do I Map it.

pLEASE HELP.

  public List<Document> defaultSortdocIds(List<Document> OdocList ){
     List<String> docId = new List<String>();
     List<String> finaldocId = new List<String>();
     List<Document> tempdoc = new List<Document>();
     for(Document d : OdocList){
     
      docId.add(d.lastupdated);
     }
      docId.sort();
      
      for(Integer i=docId.size()-1;i>=0;i--){
      
       finaldocId.add(docId.get(i));
      }
      
      
        
         for(String s : finaldocId){
          for(Document d : OdocList){
         
           if(d.lastupdated==s){
           tempdoc.add(d);
           }
         
         }
       
       }
       return tempdoc;
    }
 

 

.Thanks in Advance

Hi All 

 

I have links for document being sent from VF Page to Email

 

If a document is downloaded by the recipient, an activity history item should be created.  If the recipient views the item more than one time, still only 1 activity history item should be created.

 

May I know the approach for it.

 

Thanks

Hi All 

 

I have an issue with ordering Documents on to VF Page.  I am getting documents from an external website through integration.I am parsing them using JSON.

The fields parsed through JSON are "TITLE" and "ID"

The order in which it is displayed is (1,2,3,4,5)

It should be displayed as (5,4,3,2,1)

 Once the documents are displayed on the VF Page I can do sort function.

But the requirement is these documents should be displayed as Most recent created document on the top. 

 

Please help

 

Adil

Hi All,

I want to display Dashboards tab for community user. The community is created using Napil teplate. Iam not finding ways to display dasboards using napili template. please help.

thanks in advance.

Vedashri
Hi there,

Does Community template Napili support Reports and Dashboards ?

Thanks !
Hi I have a SOQL query that i want to reuse by changing the where clause. I dont want to repeat the SOQL multiple times. How can this be acheived. 

Here is my query 

List<Case> groupedCases = [Select Photographer_Contact__r.Name,Scheduled_Date__c from Case 
                                where RecordType.DeveloperName In('Time_Booking', 'Media_Package', 'Photography') 
                                and Scheduled_Date__c =:dates and Photographer_Contact__r.id = :con.id];
In the above query i need results without Scheduled_Date__c =:dates 
and another query I need results without Photographer_Contact__r.id = :con.id

so that i can use respective results for further processing. 
Or is there a way i can process the resultlist 'groupedcases' not to include them .?

Hi All 
I am trying to write a utility method to get only the weekdays. Is there any easy way out. here is my code so far.  The return is in the form "09/16/2014 - Tue". I just need the Date. 

public class Utility_WorkingDays {
	
	public  List<String> getHeadDates(){
        List<String> formattedDates = new List<String>();
		List<DateTime> headDates = new List<DateTime>();
		DateTime currentDate = DateTime.now();
		//Date currentDate = currentDateTime.Date;
		for (Integer idx=0; idx<28; idx++){
        	headDates.add(currentDate+idx);
	    } 
	    for(DateTime dt: headDates){
	    	String formatDatewithDay = dt.format('MM/dd/yyyy - E');
	    	formattedDates.add(formatDatewithDay);
    	   	for(Integer i = 0; i< formattedDates.size();i++){
	        	String weekend = formattedDates.get(i);
	        	system.debug('here :'+weekend);
	        	if(weekend.contains('Sun') || weekend.contains('Sat')){
	        		
	        		formattedDates.remove(i);
	        	}
        }
	      
	    }
	    system.debug('dates:'+formattedDates);
		return formattedDates;
	}
}


Hi Experts,
I am trying to render a visualforce Page with the change in picklist values. The data I would like to render is the contact names in  a table. which changes depending on the sales Region i choose. 

Here is my page and controller so far. Any help is appreciated.
<apex:page controller="PhotoSchedulerController" tabstyle="Report" sidebar="false">
<apex:form >
<apex:outputPanel id="dataBlocks" >
<apex:sectionHeader title="Field Researcher Schedule for Region"/>

<apex:selectList value="{!contactSalesRegion}" size="1" multiselect="false">
 <b>Field Researcher Schedule for Region</b><apex:selectOptions value="{!SalesRegionsCoveredValues}" > </apex:selectOptions>
<apex:actionSupport event="onchange" action="{!salesRegionCoveredFilter}" reRender="dataBlock" > 
<apex:param name="salesRegionId" assignTo="{!salesRegionId}" value="{!SalesRegionsCoveredValues}"></apex:param>  
</apex:actionSupport> 
</apex:selectList>

<apex:pageBlock >
 
<table class="list" border="0" cellpadding="0" cellspacing="0"  id="dataBlock" >

  <tr>
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;

     <b>Scheduled Date</b>
 
  </tr>
    <tr>
      
      <td>
      </td>
      <apex:repeat value="{!headDays}" var="days">
        <th style="background-color:#00BFFF;">
            {!days}
        </th>
    </apex:repeat>
    </tr>
   
    <tr class="headerRow  ">
      <th style="background-color:#00BFFF;">Photographer: Full Name</th>
      
      <apex:repeat value="{!headDates}" var="heading">
        <th style="background-color:#00BFFF;" class="headerRow ">
           {!heading}
        </th>
      </apex:repeat>
    </tr>
    <apex:repeat value="{!DataRows}" var="dRow">
       <apex:repeat value="{!dRow.contacts}" var="photo">
           <tr>
               <td style="background-color:#d4dadc;">
                  <a href="https://apartments--pre.cs20.my.salesforce.com/{!photo.Id}"> {!photo.Name} </a>
               </td>
            
            <apex:repeat value="{!dRow.cases}" var="count">
           
                <td> 
                 {!count.casenumber}
                </td>
              
            </apex:repeat>

            </tr>
         </apex:repeat>
         
    </apex:repeat>
  </table>
  </apex:pageBlock>
  </apex:outputPanel>
    </apex:form> 
</apex:page>
public class PhotoSchedulerController {

    public String salesRegionId { get; set; }
    public String ContactSalesRegion {get;set;}

    public PageReference salesRegionCoveredFilter() {
    	String contacts =  [Select Id,Name,Sales_Regions_Covered__c from Contact where Sales_Regions_Covered__c= '03'].Sales_Regions_Covered__c;
    	         system.debug('sales region:'+contacts);
    	
        return null;
    }

    public  List<SelectOption> getSalesRegionsCoveredValues() {
       List<SelectOption> options = new List<SelectOption>();
        Schema.DescribeFieldResult salesRegion = Contact.Sales_Regions_Covered__c.getDescribe();
        List<Schema.PicklistEntry> salesRegions = salesRegion.getPicklistValues();
        for(Schema.Picklistentry entry : salesRegions){
            options.add(new SelectOption(entry.getLabel(),entry.getValue()));
        }
        return options;
    } 
    
    public List<String> getHeadDays() {
        List<String> formattedDays = new List<String>();
        List<DateTime> days = new List<DateTime>();
        DateTime currentDay = DateTime.now();
        for (Integer idx=0; idx<28; idx++){
            days.add(currentDay+idx);
        system.debug('DAYS :'+days);
        } 
        for(DateTime dt: days){
            String formattedDay = dt.format('E');
            formattedDays.add(formattedDay);
        }
        return formattedDays;
    }
    
    public List<String> getHeadDates(){
        List<String> formattedDates = new List<String>();
        List<Date> dates = new List<Date>();
        Date currentDate = system.today();
        for (Integer idx=0; idx<28; idx++){
            dates.add(currentDate+idx);
        }
       
        for(Date dt: dates){
            String formattedDate = dt.format();
            formattedDates.add(formattedDate);
           
        }
        return formattedDates;
        }
        
    // retrieves the row wrapper containing the wrapped case headings
    public List<photographerRow> getDataRows(){
        List<String> scheduledDates = new List<String>();
        photographerRow pRow = new photographerRow();
        List<photographerRow> dataRows = new List<photographerRow>();
        for(Contact con : getContacts()){
            pRow.photographer = con.Name;
            pRow.photographerId = con.Id;
            pRow.contacts.add(con);
        }
        for (Integer idx=28; idx>0; idx--) {
            pRow.subtotals.add(idx);
        }
        
        for(Case c : getCaseInfo()){
            pRow.caseNumber = c.caseNumber;
            pRow.cases.add(c);
        }
    
        dataRows.add(pRow);
        return dataRows;
    }
    
    public class photographerRow{
        public String photographer {get; set;}
        public String photographerId {get;set;}
        public String caseNumber{get;set;}
        public List<Contact> contacts {get;set;}
        public List<Case> cases {get;set;}
        public List<Integer> subtotals {get; set;}
        public List<Integer> counts {get; set;}
        // constructor
        public PhotographerRow(){
            contacts = new List<Contact>();
            subtotals=new List<Integer>();
            counts=new List<Integer>();
            cases = new List <Case>();
        }
    }
    
    
    public List<Contact> getContacts(){
        List<Contact>contacts =  [Select Id,Name,Sales_Regions_Covered__c from Contact ];
        return contacts;
    }
    

    
    public List<Case> getCaseInfo(){
        List<String> contactsList = new List<String>();
        List<String> formattedDatesList = new List<String>();
        for(Contact c :  getContacts()){
                        contactsList.add(c.Name);
        }
        List<Date> dates = new List<Date>();
        Date currentDate = system.today();
        for (Integer idx=0; idx<28; idx++){
            dates.add(currentDate+idx);
        }
        system.debug('Dates List :'+dates);
        system.debug('Contact LIst :'+contactsList);
        
        List<Case> cases = [Select id,CaseNumber,Scheduled_Date__c ,Account.Owner.Name,Photographer_Contact__r.Name from Case where RecordType.DeveloperName In('Time_Booking','Media_Package','Photography') 
                                                        and Scheduled_Date__c=:dates];
        system.debug('case queried:'+cases);
        return cases;   
    }   
    
  


    /* public Integer getCaseCount(){
        Integer caseCount;
        List<AggregateResult> groupedCases = [Select count(casenumber),Scheduled_Date__c, Photographer_Contact__r.Name from Case where RecordType.DeveloperName In('Time_Booking', 'Media_Package', 'Photography') and Scheduled_Date__c!=null group by Photographer_Contact__r.Name,Scheduled_Date__c];
        for (AggregateResult ar : groupedCases)  {
                caseCount = Integer.valueOf(ar.get('expr0'));
        }
    return caseCount;
    }*/
}
Thanks for the expert advice. 
Adil

Hi All 

I would like to replicate the attached report in visualforce . 
I want the column headers  to hold the weekdays as shown .
The data in the columns is from Case Object. 0's and 1's represent the number of case records on that particualr day. 
Is there any easy way out.Report to be transformed to Visualforce

Check box to Select All on VF Page. I am trying this but no go

 

<apex:page standardController="Listing__c"   extensions="TFNController" id="myPage" showHeader="false">
  
 
       <apex:pageMessages id="messages"/> 
 <apex:form id="myform" >

<apex:PageBlock title="TFN Provisioning for Listing :" />
<apex:PageBlock id="pageload">
  <apex:PageBlockSection columns="1" id="theSection" > 
<apex:outputPanel style="vertical-align:top" >
  <table border="1" class="list" width="100%" cellpadding="0" cellspacing="0" id="aheadertable" >
                 <tr >  
                
                  <td width="2%"  style="font-weight:bold;text-align:center;vertical-align:bottom" rowspan='2'><b>
                    <apex:inputCheckbox id="SelectAll"   onclick="selectAll()" /></b></td>
</tr>
  </table>  
            </apex:outputPanel> 
           <apex:outputPanel style="vertical-align:top" id="test">
      <apex:repeat var="TFNAffiliate" value="{!TFNVFResults}" id="TFNAffiliateId"> 
                     <table border="0" width="100%" class="list" cellpadding="0" cellspacing="0" id="atable" >
                        <tr class="row" style="persist: location;">
                            <td width="2%" style="text-align:center" >
                             <apex:inputCheckbox id="select" value="{!TFNAffiliate.selected}" styleclass="select" /> 
                           </td>
 </table> 
                   </apex:repeat>   
                   </apex:outputPanel>    
                  </apex:PageBlockSection> 
                      </apex:PageBlock>
                           </apex:form>
<script>
function selectAll()
 {
   // var listSize = {!TFNVFResults.size};
   // alert(!TFNVFResults.size);
   // var i;
     var select;
  var selectall =  document.getElementById('{!$Component.myPage.myform.pageload.theSection.selectAll}');


  //if (selectall.checked){
  alert(selectall.value);
   
 // }
for (i = 0; i < listSize; i++) {
          
      select = document.getElementById('myPage:myform:pageload:theSection:TFNAffiliateId:'+i+':select}');
      }
 alert('test'+select.value);
 }
 </script>
   
</apex:page>

 

All

 

Here is my query

 

orderHistListRec33 = [Select Name,Account__c,Order_Status__c, Case_Number__c, Product_Description__r.Is_Package__c, Product_Description__r.Name,CreatedDate
From Order_History__c order by createdDate dsc ];

 

I get 

 

 

List is 

 

OrderHistoryNumber (Name): 123    Product_Description__r.Name:Branding    CreatdeDate : 6/25/13

OrderHistoryNumber(Name) : 124    Product_Description__r.Name:CHAT    CreatdeDate : 6/25/13

OrderHistoryNumber (Name): 125    Product_Description__r.Name:Branding   CreatdeDate : 6/22/13

OrderHistoryNumber(Name) : 126     Product_Description__r.Name:CHAT    CreatdeDate : 6/22/13

 

I want to eleiminate duplicate Product_Description__r.Name and get most recent i.e. 

 

 

OrderHistoryNumber (Name): 123    Product_Description__r.Name:Branding    CreatdeDate : 6/25/13

OrderHistoryNumber(Name) : 124    Product_Description__r.Name:CHAT    CreatdeDate : 6/25/13

 

how do i modify my query .

Is it Possible to Convert a Visualforce Page as a Image.

Hello all, 

 

I have created a sortable table using the jquery tablesort plugin and I am having trouble figuring out how to change a cell background color in the table I'm creating based on a condition.  Using <td style=background:..."  works as setting a static color, but this isn't what I need.  I am trying to get this working on the test_stat_c cells.  Since it is a number I am  trying to accomplish this condition {!IF(u.test_stat__c < 4 ,'#7CFC00', '#FFA07A')}">

 

I've tried putting it in several places inside the repeat segment, but not having any luck.  Is it even possible?  Would I have to write something into the <script> for this to work?  I need to use the tablesorter for obvious reasons.  I've tried searching around, but all I could find were resources to accomplish this using pageblock tables.

 

Thank you for your help,

 

Les

 

and the code:

 

<apex:page standardController="stat_page__c" standardstylesheets="true" sidebar="false" >
    
    <apex:stylesheet value="{!URLFOR($Resource.jquerySort, 'js/themes/blue/style.css')}"  />
    <apex:stylesheet value="{!URLFOR($Resource.jquerySort, 'css/ui-lightness/jquery-ui-1.8.6.custom.css')}"  />
    
    <script type="text/javascript" language="javascript"  src="{!URLFOR($Resource.jquerySort, 'js/jquery-latest.js')}"></script>
    <script type="text/javascript" language="javascript"  src="{!URLFOR($Resource.jquerySort, 'js/jquery.tablesorter.min.js')}"></script>


</style>

<apex:form >

<apex:sectionHeader title="for stats" />
<apex:outputPanel id="js">
      <script language="javascript" type="text/javascript">
      var j$ = jQuery.noConflict();
      
            function Loading(b){
                  if(b){
                        j$('.loadingIcon').removeClass('hideIt');
                  }else{
                        j$('.loadingIcon').addClass('hideIt');
                  }
            }
            j$(document).ready(function(){
                  j$("#tableToSort").tablesorter({
                    headers: {
                        0: {sorter: 'text'},
                        1: {sorter: 'digit'},
                        2: {sorter: 'digit'},
                        3: {sorter: 'digit'}
                    }
                });
            });   
      </script>
</apex:outputPanel>

<apex:outputPanel id="table">     
      <table id="tableToSort" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
      <thead class="rich-table-thead">
            <tr class="headerRow">
                  <th colspan="1" scope="col">Agent</th>
                  <th colspan="1" scope="col">First Break</th>
                  <th colspan="1" scope="col">Lunch Break</th>
                  <th colspan="1" scope="col">Second Break</th>
                  <th colspan="1" scope="col">test stat</th>
            </tr>
      </thead>
      <tbody>
            <apex:repeat value="{!agent_page__c.reps__r}" var="u">
            <tr class="dataRow">
                  <td><apex:outputLink value="/{!u.id}" target="_Blank">{!u.name}</apex:outputLink></td>
                  <td align="center">{!u.first_break__c}</td>
                  <td>{!u.lunch_break__c}</td>
                  <td>{!u.second_break__c}</td>
                  <td>{!u.test_stat__c}</td>          
            </tr>                                   
            </apex:repeat>
      </tbody></table>
</apex:outputPanel>

</apex:form>
</apex:page>

 

I have requirement, which is as follows..

When a user selects a particular Agent Id , all the details of that particular Agent Id should get populated on the visual force page.... I am not able to capture the selected picklist value and pass it to the Apex Controller ... Please help me..

Please guide as to where am I going wrong...

 

Class

 

public class AgentandOrderController{
Agent__c Agent;
string searchText;
List<Agent__c> result;
Integer selected;
Integer AgentId;

public String getAgent() {
        return null;
    }

 public List<Agent__c> getresult() {
      return result;
   }

public Integer getAgentId() {
return selected;
}

public void  setAgentId(Integer val) {
selected=val;
 }
 
public List<SelectOption> getItems() {
     List<SelectOption> options = new List<SelectOption>();
     options.add(new selectOption('001', '001'));
     options.add(new selectOption('002', '002'));
     options.add(new selectOption('003', '003'));
     options.add(new selectOption('004', '004'));
    
     return options;
}

public PageReference search() {
result=[select Agent_Address__c from Agent__c where Name=: ApexPages.currentPage().getParameters().get('options')];
System.debug('options : '+options);
return null;
}

}

 

 

 

Page

 

<apex:page controller="AgentandOrderController" >
 <apex:form >
<b>Agent Information</b>
  <apex:pageblock >
   <apex:pageBlockSection id="section1">
    <apex:pageBlockSectionItem >
     <apex:panelGrid columns="2">
     <apex:actionRegion >     
     <apex:outputLabel value="Agent Id" for="agentId"/>
      <apex:selectList value="{!agentId}" multiselect="false" size="1" onchange="search()" >
      <apex:selectOptions value="{!items}" />
      </apex:selectList>
     </apex:actionRegion>        
</apex:panelGrid>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>

<b>Order Information</b>
<apex:pageBlock >
<apex:pageBlockSection id="section2">
<apex:pageBlockSectionItem >
<apex:panelGrid columns="2">
</apex:panelGrid>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Thank You

  • April 05, 2012
  • Like
  • 0

I have based this code off of the VF Quote tool created by Salesforce.com Labs a couple of years back.

 

Esentially, I'm trying to take similar line items and get rid of them from the List and aggregate the quantity.  I end up with extra lines in my list for some reason.  I have a feeling it's because I'm trying to remove elements while in the loop, but I can't figure out another way to do this.

 

Any help is appreciated.

 

 

Quote_Item__c[] items = new Quote_Item__c[]{};
Quote_Item__c[] qiList = new Quote_Item__c[]{};

for(OpportunityLineItem oli:[select Maintenance_End__c, Maintenance_Start__c, quantity, unitprice, ListPrice, pricebookEntry.product2.name, pricebookEntry.product2id, pricebookEntry.product2.sort__c from opportunitylineitem where opportunityid = :opptyId order by pricebookEntry.product2.sort__c ASC]) 
{
	qiList.add(new Quote_Item__c(quantity__c = oli.quantity, unit_price__c = oli.unitprice, List_Price__c = oli.ListPrice, quote__c = renewalQuote.id, name = oli.pricebookentry.product2.name, sort__c = oli.pricebookentry.product2.sort__c, product__c = oli.pricebookentry.product2id, Maintenance_End__c = oli.Maintenance_End__c, Maintenance_Start__c=oli.Maintenance_Start__c));
}

// Iterate through working list
while(qiList.size()>0){
	Set<Id> removeAddress = new Set<Id>();
	Quote_Item__c qiTemp = qiList.get(0);
	removeAddress.add(qiTemp.Id);
	for(Quote_Item__c qi :qiList){
		If(qi.name==qiTemp.name && qi.unit_price__c==qiTemp.unit_price__c && qi.Maintenance_End__c==qiTemp.Maintenance_End__c && qi.Maintenance_Start__c==qiTemp.Maintenance_Start__c)
			{
				removeAddress.add(qi.id);
				qiTemp.Quantity__c += qi.Quantity__c;
			}
	}
	items.add(qiTemp);
	for(Id a : removeAddress){
		for(Integer i=0; i < qiList.size(); i++){
			if(a == qiList.get(i).Id)
			{
				qiList.remove(i);
			}
		}
	}
}

 

 

We have been experiencing odd behavior with the "Password Never Expires" capability on the profiles and I was wondering if anyone else has experienced the same.
 
We have integrations built that access SFDC through the API.  We created separate user accounts and profiles for these integrations.  The integration profiles have been marked as "API Only" and "Password Never Expires".  We want to preserve the password considering this is an integration account.
 
For our regular users (non integration) we have established the password policies with "password expires 90 days".  Therefore, users are forced to change their passwords every 90 days.
 
Our integration user accounts have been getting the following error when trying to login using our integration or any other api application, such as the data loader:
Web service callout failed: WebService returned ­a SOAP fault:
INVALID_OPERATION_WITH_EXPIRED_PASSWORD: The user’s password has expired, You must call
SetPassword before attempting any other API operations
Faultcode=sf: INVALID_OPERATION_WITH_EXPIRED_PASSWORD
 
Although this error is produced when attempting to login through the integration account -- if the login history is viewed for this specific user, the history displays the login as "Successful".  In addition, we reset the password on the integration user account and the integrations continue to work ... for approx. 90 days then the same thing happens.  The same behavior happens in our sandbox environment.
 
I have contacted SFDC support but they do not seem to know what is causing this issue and their recommendation is to reset the password so they can monitor that account and see if it happens again.  It seems to me that the password policies are not adhering to the "password never expires" on the "API Only" integration accounts.
 
Please let me know if anyone has experienced the same behavior or has any additional information regarding this issue.
 
Thank you

 

 

  • January 12, 2009
  • Like
  • 1