Posts

Showing posts from 2012

How to use environment variables in C# for File IO

Use  Environment . ExpandEnvironmentVariables http://stackoverflow.com/questions/9993561/c-sharp-open-file-path-starting-with-userprofile 

Roman Number Conversion

http://weblogs.asp.net/rternier/archive/2006/04/26/how-to-generate-roman-numerals.aspx

How to bundle multiple actions as a transaction using Salesforce API?

How to bundle multiple actions as a transaction using Salesforce API? At present, the only way to bundle multiple actions as a transaction in SFDC is to put all of them in an APEX method and make it a web service.  But, the problem one may encounter is with the arguments. The arguments tend to get misinterpreted or overlapped at Salesforce end. For example in the following definition  webService static String upsertData(string s,Id v, Id[] str) ,  if we pass v as null one of the str values is pushed into v variable. This situation is undesirable and results in unwanted results. So we should define a class defining all the argument we want to pass in a method. And use the class as an argument. This worked perfectly for me. Solution: global class xxxxxx{     global class yyyyyyy{         webService Attachment qAttach;      ...

Sample SF Questions

1.       Can we bypass governor limits using time based workflows? No. Time-dependent actions aren't executed independently. They're processed several times every hour, where they're grouped together and executed as a single batch. Therefore, any triggers that fire as a result of those grouped actions are also executed in a single batch. This behavior can cause you to exceed your Apex governor limits if you design your time-based workflow in conjunction with Apex triggers. 2.       What is JavaScript remoting?  The RemoteAction annotation provides support for Apex methods used in Visualforce to be called via Javascript. This process is often referred to as Javascript remoting. 3.       What does RemoteAction annotation used for?  The RemoteAction annotation provides support for Apex methods used in Visualforce to be called via Javascri...

Capturing Raw SOAP Requests

Option 1: SOAP Extentions Option 2:  An alternative to SoapExtensions is to implement IHttpModule and grab the input stream as it's coming in Reference :  http://stackoverflow.com/questions/2624621/capturing-soap-requests-to-an-asp-net-asmx-web-service

List of List in VisualForce

// VF Page <apex:repeat value="{!MyTrows}" var="rows"> <apex:repeat value="{!MyTcols}" var="cols"> <apex:outputText value="{!MyT[rows][cols]}" /> </apex:repeat> </apex:repeat> //Controller public List> MyT{ get{ List a=new List{'a','b','c'}; List b=new List{'d','e','f'}; List> ab=new List>{a,b}; return ab; } set; } public List MyTcols{ get{ return new List{0, 1, 2}; } set; } public List MyTrows{ get{ return new List{0, 1}; } set; }

Advanced MSDOS Redirection commands

Here is the good links about MSDOS redirection http://www.robvanderwoude.com/redirection.php http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true  

Batch Apex and Scheduled Apex

This is one of the blog posts I found for interesting with respect to using both Batch Apex and Scheduled apex. http://corycowgill.blogspot.in/2010/12/leveraging-scheduled-apex-to-link-batch.html Database.executeBatch (part of apex batch) takes a parameter called scope which specifies the number of records that should be passed into the execute method. More info: “Each execution of a batch Apex job is considered a discrete transaction. For example, a batch Apex job that contains 1,000 records and is executed without the optional scope parameter from Database.executeBatch is considered five transactions of 200 records each. The Apex governor limits are reset for each transaction.” Also, we can use Database.Stateful in the class definition to make the batch remember the static variables. “If you specify Database.Stateful in the class definition, you can maintain state across these transactions. This is useful for counting or summarizing records as they...

Uploading a document or file to Salesforce

I have done a small POC for uploading a file through Salesforce API.  C# binding = new SforceService(); binding.Timeout = 60000; LoginResult lr; try { Console.WriteLine("LOGGING IN NOW..."); lr = binding.login(username, password); } catch (SoapException e) { } private void uploadFile() { QueryResult qr = null; binding.QueryOptionsValue = new QueryOptions(); binding.QueryOptionsValue.batchSize = 250; binding.QueryOptionsValue.batchSizeSpecified = true; Folder rF=null; try { qr = binding.query("SELECT AccessType, Id, DeveloperName, Name, NamespacePrefix, IsReadonly, Type FROM Folder where DeveloperName='WSDLUpload'"); if (qr.size > 0) { Console.Write...

Will Salesforce work with cookies disabled?

Please check this out. http://www.salesforce.com/company/privacy/full_privacy.jsp#nav_info From my end, I am not able to login without cookies. 

Doing a case sensitive search in a case insensitive SQL server

SELECT   *   FROM  dbo . CaseSensitiveTest WHERE  Value1  LIKE   '%Test%'   Collate  SQL_Latin1_General_CP1_CS_AS GO http://www.mssqltips.com/sqlservertip/1032/case-sensitive-search-on-a-case-insensitive-sql-server/

UNPIVOT: Columns to rows

Q : Write a query to format the columns of a table to rows? A : Lets say there is a table  DECLARE @t TABLE (     SquadID INT,      Date DATETIME,      Q01 VARCHAR(10),      Q02 VARCHAR(10),      Q03 VARCHAR(10),      A01 VARCHAR(10),      A02 VARCHAR(10),          A03 VARCHAR(10)) INSERT INTO @t(SquadID, Date,  Q01, Q02, Q03, A01, A02, A03) SELECT 123,'2008-09-19','5.1','2.1','3.0','DEG','ABC','CDE' I want a query to display results as below Q1 A1 Q2 A2 Q3 A3 This is not straight forward we can use UNPIVOT to achieve this to some extend.  And, where clause does the trick. I found this on Internet.  select ROW_NUMBER() OVER(ORDER BY Question_ID), Question, Answer FROM  (SELECT Q01,Q02,Q03,A01,A02,A03 FROM @t) p UNPIVOT    (Question FOR Question_ID IN        (Q01,Q02,Q03)...

How to package a single workflow using Force.com Migration tool?

Extracting a single workflow out of force.com can be a little tricky. I am using ANT/JAVA migration tool to extract force.com metadata. From the documentation it is clear that 'Workflow' tag should be used to extract workflow. <types><members>*</members><name>Workflow</name></types> The above component in project manifest - package.xml will fetch all the workflows related to Opportunity. How to fetch a specific workflow? dot operator will not work in this case. One way to get around this limitation is specifying the following components related to a workflow as appropriate. WorkflowAlert WorkflowFieldUpdate WorkflowOutboundMessage WorkflowRule WorkflowTask For example, a workflow sends an email and does a field update upon meeting a certain criterion. In package.xml, the following components should be included.  <types> <members>Opportunity.Set_Date</members><name>WorkflowFieldUpdate</name>...

Accessing cross object merge fields in Salesforce

At present accessing cross object merge fields in email templates is not possible. You need to create a formula field pointing to the related object's custom field. Also if the related object's field's type is of "Long Text", it won't show up in advanced formula editor while creating the field. We should choose alternative type Text Area.  Reference:  http://success.salesforce.com/ideaView?id=08730000000Brk7AAC

Prominent limitation of time based workflow for batch processing

I was going through the following link about time based workflows. My aim was to avoid governor limits encountered for a class implementing Apex Schedulable interface. For a while time based workflow seems to be an alternative.  Time based workflow queues its tasks. If the tasks are above the limit, it executes the left over tasks in the current run in the next hourly run. But, the following limitation may make the time based workflow unpredictable. https://login.salesforce.com/help/doc/en/workflow_time_action_considerations.htm Time-dependent actions aren't executed independently. They're processed several times every hour, where they're grouped together and executed as a single batch. Therefore, any triggers that fire as a result of those grouped actions are also executed in a single batch. This behavior can cause you to exceed your   Apex   governor limits if you design your time-based workflow in conjunction with   Apex   triggers. ...