• Thimo
  • NEWBIE
  • 0 Points
  • Member since 2012


  • Chatter
    Feed
  • 0
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies
For anyone who may have faced the same task, here is a sample code for displaying filtered tasks and events to display in Account details.
As you may see, I've filtered the results via SOQL, you may extend the code to improve or anything else :)
I used a workaround for reading the events, because they are not readable via the 15 digits AccountId but with the 18 digit once. Crazy, but it works. All of you may correct me, if this may not be usable in future.

1) Add a apex class:
public with sharing class RelatedActivitesTest {
public List<Task> tasksLimited {get;set;}
public List<Event> eventsLimited {get;set;}
public List<Contact> conts {get;set;}
public RelatedActivitesTest(ApexPages.StandardController con){
conts = [SELECT id FROM Contact WHERE AccountId =:ApexPages.currentPage().getParameters().get('id')];
tasksLimited= [select id,activitydate,createdbyid,description,subject,whoid,type,ownerid from task
where (
accountid=: ApexPages.currentPage().getParameters().get('id') or
WhoId in :conts
) and
subject not in ('Rechnung per E-Mail','Rechnung erstellt','Box-Austausch erstellt','Support angelegt','Gutschrift erstellt','Lizenzdatei per E-Mail','Webroot-Lizenzzertifikat per E-Mail','Teilgutschrift erstellt','PreSales angelegt','Angebot per E-Mail')
order by activitydate desc limit 1000];
// Used convertID to get the external url repesantation of Account Id, which helps me getting all events. Internal Ids won't work somehow.
eventsLimited= [select id,activitydate,createdbyid,description,subject,whoid,type,ownerid,whatid FROM Event
WHERE (
WhatId =:convertID(ApexPages.currentPage().getParameters().get('id')) or
WhoId =:convertID(ApexPages.currentPage().getParameters().get('id')) or
AccountId =:convertID(ApexPages.currentPage().getParameters().get('id')) or
WhoId in :conts
) and
subject not in ('Rechnung per E-Mail','Rechnung erstellt','Box-Austausch erstellt','Support angelegt','Gutschrift erstellt','Lizenzdatei per E-Mail','Webroot-Lizenzzertifikat per E-Mail','Teilgutschrift erstellt','PreSales angelegt','Angebot per E-Mail')
order by activitydate desc limit 1000];
}
public static String convertID(String id){
if(id.length() == 18) return id;
String suffix = '';
for(Integer i=0;i<3;i++){
Integer flags = 0;
for(Integer j=0;j<5;j++){
String c = id.substring(i*5+j,i*5+j+1);
if(c.compareTo('A') >= 0 && c.compareTo('Z') <= 0){
flags += 1 << j;
}
}
if (flags <= 25) {
suffix += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.substring(flags,flags+1);
}else suffix += '012345'.substring(flags-26,flags-26+1);
}
return id+suffix;
}
}


Create a visual force page:
<apex:page standardController="Account" extensions="RelatedActivitesTest" tabStyle="Account">
<apex:pageBlock title="Filtered Events">
<apex:outputPanel layout="block" style="overflow:auto;width:100%;height:200px">
<apex:dataTable value="{!eventsLimited}" var="eventLimited" cellpadding="4" bgcolor="white" rowClasses="even,odd">
<apex:column headerValue="Subject">
<apex:outputLink value="/{!URLFOR(eventLimited['id'])}">{!eventLimited.subject}</apex:outputLink>
</apex:column>
<apex:column headerValue="Description">
<apex:outputtext value="{!LEFT(eventLimited.description, 150)}" />
</apex:column>
<apex:column value="{!eventLimited.whoid}" headerValue="Member" />
<apex:column value="{!eventLimited.type}" headerValue="Type" />
<apex:column value="{!eventLimited.activitydate}" headerValue="Activity Date" />
<apex:column value="{!eventLimited.ownerid}" headerValue="Assigned To" />
</apex:dataTable>
</apex:outputPanel>
</apex:pageBlock>
<apex:pageBlock title="Filtered Tasks">
<apex:outputPanel layout="block" style="overflow:auto;width:100%;height:200px">
<apex:dataTable value="{!tasksLimited}" var="taskLimited" cellpadding="4" bgcolor="white" rowClasses="even,odd">
<apex:column headerValue="Subject">
<apex:outputLink value="/{!URLFOR(taskLimited['id'])}">{!taskLimited.subject}</apex:outputLink>
</apex:column>
<apex:column headerValue="Description">
<apex:outputtext value="{!LEFT(taskLimited.description, 150)}" />
</apex:column>
<apex:column value="{!taskLimited.whoid}" headerValue="Member" />
<apex:column value="{!taskLimited.type}" headerValue="Type" />
<apex:column value="{!taskLimited.activitydate}" headerValue="Activity Date" />
<apex:column value="{!taskLimited.ownerid}" headerValue="Assigned To" />
</apex:dataTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:page>


The visualforce page is connected to Account so you can add it to the Account view in your pagelayout.
If you want to change the filter, just change them to fit your needs.

Anyway, if you like my first post, give me a "like".

Thanks
Thimo
 
  • November 26, 2014
  • Like
  • 6

Hi,

 

I want to send out emails from web to lead to the customer - which isn't that problem - but this email should include a unique trial license key. For the key management I would use a custom object, but I don't know how to connect the key to the email (and to this unique user), display it in the mail and send it out.

 

Does anyone have a simple solution for this?

 

 

Thanks in advanced

Thimo

  • August 26, 2013
  • Like
  • 0

Hi folks,


I just created a Task using the PHP Toolkit, with all appropritate Data:

      $aObject->OwnerId = $_sfUserId;
      $aObject->WhatId = $_sfAccountId;
      $aObject->WhoId = $_sfContactId;
      $aObject->Subject = "Angebot per E-Mail";
      $aObject->Description = $message;
      $aObject->ActivityDate = date("c");
      $aObject->Status = "Abgeschlossen";


But the Chatter doesn't display the change or the new Task.

What can I do?

Do I have to create a separate Chatter message?


Thanks for help!

Thimo

  • July 20, 2012
  • Like
  • 0

Hi folks,

 

I just created a Task using the PHP Toolkit, with all appropritate Data:

 

      $aObject->OwnerId = $_sfUserId;
      $aObject->WhatId = $_sfAccountId;
      $aObject->WhoId = $_sfContactId;
      $aObject->Subject = "Angebot per E-Mail";
      $aObject->Description = $message;
      $aObject->ActivityDate = date("c");
      $aObject->Status = "Abgeschlossen";

But the Chatter doesn't display the change or the new Task.

What can I do?

 

Do I have to create a separate Chatter message?

 

 

Thanks for help!

 

Thimo

  • July 16, 2012
  • Like
  • 0
Hi, could you please tell me, how to disable a single contact completly without deleting and e.g. not showing the emailadress and telefon number? (Enabling of the contact should only be able for the admins) Thanks!
  • February 21, 2012
  • Like
  • 0
For anyone who may have faced the same task, here is a sample code for displaying filtered tasks and events to display in Account details.
As you may see, I've filtered the results via SOQL, you may extend the code to improve or anything else :)
I used a workaround for reading the events, because they are not readable via the 15 digits AccountId but with the 18 digit once. Crazy, but it works. All of you may correct me, if this may not be usable in future.

1) Add a apex class:
public with sharing class RelatedActivitesTest {
public List<Task> tasksLimited {get;set;}
public List<Event> eventsLimited {get;set;}
public List<Contact> conts {get;set;}
public RelatedActivitesTest(ApexPages.StandardController con){
conts = [SELECT id FROM Contact WHERE AccountId =:ApexPages.currentPage().getParameters().get('id')];
tasksLimited= [select id,activitydate,createdbyid,description,subject,whoid,type,ownerid from task
where (
accountid=: ApexPages.currentPage().getParameters().get('id') or
WhoId in :conts
) and
subject not in ('Rechnung per E-Mail','Rechnung erstellt','Box-Austausch erstellt','Support angelegt','Gutschrift erstellt','Lizenzdatei per E-Mail','Webroot-Lizenzzertifikat per E-Mail','Teilgutschrift erstellt','PreSales angelegt','Angebot per E-Mail')
order by activitydate desc limit 1000];
// Used convertID to get the external url repesantation of Account Id, which helps me getting all events. Internal Ids won't work somehow.
eventsLimited= [select id,activitydate,createdbyid,description,subject,whoid,type,ownerid,whatid FROM Event
WHERE (
WhatId =:convertID(ApexPages.currentPage().getParameters().get('id')) or
WhoId =:convertID(ApexPages.currentPage().getParameters().get('id')) or
AccountId =:convertID(ApexPages.currentPage().getParameters().get('id')) or
WhoId in :conts
) and
subject not in ('Rechnung per E-Mail','Rechnung erstellt','Box-Austausch erstellt','Support angelegt','Gutschrift erstellt','Lizenzdatei per E-Mail','Webroot-Lizenzzertifikat per E-Mail','Teilgutschrift erstellt','PreSales angelegt','Angebot per E-Mail')
order by activitydate desc limit 1000];
}
public static String convertID(String id){
if(id.length() == 18) return id;
String suffix = '';
for(Integer i=0;i<3;i++){
Integer flags = 0;
for(Integer j=0;j<5;j++){
String c = id.substring(i*5+j,i*5+j+1);
if(c.compareTo('A') >= 0 && c.compareTo('Z') <= 0){
flags += 1 << j;
}
}
if (flags <= 25) {
suffix += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.substring(flags,flags+1);
}else suffix += '012345'.substring(flags-26,flags-26+1);
}
return id+suffix;
}
}


Create a visual force page:
<apex:page standardController="Account" extensions="RelatedActivitesTest" tabStyle="Account">
<apex:pageBlock title="Filtered Events">
<apex:outputPanel layout="block" style="overflow:auto;width:100%;height:200px">
<apex:dataTable value="{!eventsLimited}" var="eventLimited" cellpadding="4" bgcolor="white" rowClasses="even,odd">
<apex:column headerValue="Subject">
<apex:outputLink value="/{!URLFOR(eventLimited['id'])}">{!eventLimited.subject}</apex:outputLink>
</apex:column>
<apex:column headerValue="Description">
<apex:outputtext value="{!LEFT(eventLimited.description, 150)}" />
</apex:column>
<apex:column value="{!eventLimited.whoid}" headerValue="Member" />
<apex:column value="{!eventLimited.type}" headerValue="Type" />
<apex:column value="{!eventLimited.activitydate}" headerValue="Activity Date" />
<apex:column value="{!eventLimited.ownerid}" headerValue="Assigned To" />
</apex:dataTable>
</apex:outputPanel>
</apex:pageBlock>
<apex:pageBlock title="Filtered Tasks">
<apex:outputPanel layout="block" style="overflow:auto;width:100%;height:200px">
<apex:dataTable value="{!tasksLimited}" var="taskLimited" cellpadding="4" bgcolor="white" rowClasses="even,odd">
<apex:column headerValue="Subject">
<apex:outputLink value="/{!URLFOR(taskLimited['id'])}">{!taskLimited.subject}</apex:outputLink>
</apex:column>
<apex:column headerValue="Description">
<apex:outputtext value="{!LEFT(taskLimited.description, 150)}" />
</apex:column>
<apex:column value="{!taskLimited.whoid}" headerValue="Member" />
<apex:column value="{!taskLimited.type}" headerValue="Type" />
<apex:column value="{!taskLimited.activitydate}" headerValue="Activity Date" />
<apex:column value="{!taskLimited.ownerid}" headerValue="Assigned To" />
</apex:dataTable>
</apex:outputPanel>
</apex:pageBlock>
</apex:page>


The visualforce page is connected to Account so you can add it to the Account view in your pagelayout.
If you want to change the filter, just change them to fit your needs.

Anyway, if you like my first post, give me a "like".

Thanks
Thimo
 
  • November 26, 2014
  • Like
  • 6
It's bizarre. I'm using Pythons simple-salesforce module. Everything worked fine for months.

Today however, sometimes, my requests go through fine. Other times, I get a:

SalesforceAuthenticationFailed: INVALID_LOGIN: Invalid username, password, security token; or user locked out.

I've reset my token, refreshed my sandbox, tried connecting to both production and test - always the same outcome.

Every 10+ requests fail, then 1 goes through.

I feel this is definitely an issue with Salesforce, but have no idea how to get through to them.

Any help much appreciated.

Hi,

 

I want to send out emails from web to lead to the customer - which isn't that problem - but this email should include a unique trial license key. For the key management I would use a custom object, but I don't know how to connect the key to the email (and to this unique user), display it in the mail and send it out.

 

Does anyone have a simple solution for this?

 

 

Thanks in advanced

Thimo

  • August 26, 2013
  • Like
  • 0

Hi folks,


I just created a Task using the PHP Toolkit, with all appropritate Data:

      $aObject->OwnerId = $_sfUserId;
      $aObject->WhatId = $_sfAccountId;
      $aObject->WhoId = $_sfContactId;
      $aObject->Subject = "Angebot per E-Mail";
      $aObject->Description = $message;
      $aObject->ActivityDate = date("c");
      $aObject->Status = "Abgeschlossen";


But the Chatter doesn't display the change or the new Task.

What can I do?

Do I have to create a separate Chatter message?


Thanks for help!

Thimo

  • July 20, 2012
  • Like
  • 0

Hi folks,

 

I just created a Task using the PHP Toolkit, with all appropritate Data:

 

      $aObject->OwnerId = $_sfUserId;
      $aObject->WhatId = $_sfAccountId;
      $aObject->WhoId = $_sfContactId;
      $aObject->Subject = "Angebot per E-Mail";
      $aObject->Description = $message;
      $aObject->ActivityDate = date("c");
      $aObject->Status = "Abgeschlossen";

But the Chatter doesn't display the change or the new Task.

What can I do?

 

Do I have to create a separate Chatter message?

 

 

Thanks for help!

 

Thimo

  • July 16, 2012
  • Like
  • 0
Hi, could you please tell me, how to disable a single contact completly without deleting and e.g. not showing the emailadress and telefon number? (Enabling of the contact should only be able for the admins) Thanks!
  • February 21, 2012
  • Like
  • 0