• indy
  • NEWBIE
  • 4 Points
  • Member since 2009
  • Salesforce Consultant
  • Cognizant

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 43
    Questions
  • 43
    Replies
A string value is being concatenated in Apex class and the value is passed from Flow 1 to Flow 2.(Flow 2 is sub flow).
The individually declared string variables are concatenated without any issues but the concatenated List values are displayed only in Flow 1 but not in Flow 2.
i.e. As per the below code, when Flow 1 invokes apex action(AddString.mainMethod), The final concatenated string 'finalString' is showing the results in Flow 1, but when we pass the same 'finalString' value to Flow 2, only the first concatenation method results i.e. stringSet1() are showing and not the data from the method stringSet2.

 
public class wrapper{

     @AuraEnabled @InvocableVariable
     public string str1;

     @AuraEnabled @InvocableVariable
     public string str2;

     @AuraEnabled @InvocableVariable
     public string str3;

     @AuraEnabled @InvocableVariable
     public List<String> stringArray;
    }
    
    public class AddString{
     
     @InvocableMethod
     public static List<String> mainMethod(List<Wrapper> wrap){
       String finalString = stringSet1(wrap.get(0))+stringSet2(wrap.get(0).inputSet));
       return new List<String>{finalString};
     }
     private static string stringSet1(wrapper wr){
        return wr.str1+'\n'+wr.str2+'\n'+wr.str3+'\n';
     }
     
     private static string stringSet2(List<String> strSet){
         String tempStr;
         for(String str: strSet){
            tempStr+= strSet+'\n';
         }
         return strSet;
     }
    }

 
  • May 17, 2022
  • Like
  • 0
We have an existing implementation where Flow 1 publishes the event and Flow 2 subscribes to the same event and processes the apex logic. The apex logic includes callout and updating the Lead. Out of 1000+ data in production, a handful of records are not subscribed by Flow 2(or not published by Flow 1).
part of troubleshooting, we came to know that -
  1. It is not a permission issue. other successful records were published by the same users.
  2. It is not a callout issue as well. The callout system doesn't have any log entries.

It is obvious that either Flow 1 is not published the event or Flow 2 is not subscribed to the event. But we don't have any technical way to prove that. How to draw the conclusion or troubleshoot or provide proof for these issues, especially in production.

Enabling the debug logs for user/automation users is not an option now, as it is eating the space within seconds.
  • May 05, 2022
  • Like
  • 0
I am not able to show the custom validation error message as a result of  callback method.

Controller.js
saveCase : function(component, event, helper){
       //existing validations...
       var validTab1 = helper.validateTab1(component); 
       var validTab2 = helper.validateTab2(component); 
       
        //New validaiotn      
        var isValidDate =           helper.validateExtDate(component);
        // Other business validations....
        helper.createCase(compoent);

}


Helper.js
 
validateExtDate:function(component)
{
    var caseRec = component.get("v.case");
    var action = component.get("c.getResponseDeadlineOnEdit");
    action.setParams({
                                "cs":caseRec
    });

    action.setCallback(this,function(response){
             this.processresults(response, component);
    });
    $A.enqueueAction(action);
},

processresults : function(response,component) {
    var extnsDate = component.find("respExtdate");
    var extnsDateVal = extnsDate.get("v.value");
    var extDate = new Date(extnsDateVal);

    var state = response.getState();
    if(state === "SUCCESS") {
         var deadlinedate= response.getReturnValue();      
         if(extDate <=  deadlineDate) {
                    extnsDate.set("v.errors", [{message: "Please select a different date” }]);
        }
}

The contoller.js is executing all the helper methods including the new asynch/callback method in helper.  But it is not stopping the flow if the custom validation occurs. i.e Due to asynch behaviour the flow is executing the existing createCase method, which save the case even if there is a validation. 
  • July 19, 2019
  • Like
  • 0
My use case is to calculate the deadline to respond on the Case. Rule is to add 10 business days from the complaint received date.
1.    Defined the business hours:
 User-added image2. Logic 1
 
Date initialDate = Complaint_Receive__c;
	Datetime datetime = datetime.newInstance(initialDate.year(), initialDate.month(),initialDate.day());
	Datetime deadline = BusinessHours.addGmt (stdBusinessHours.id, datetime, 10 * 24 * 60 * 60 * 1000L);
	Datetime casedeadline = date.newinstance(deadline.year(), deadline.month(), deadline.day());

If the Complaint Received date is 04/01 then the deadline should be 04/15. But the above logic is returning 04/13 which is Saturday.
But if I change the logic to the below it is returning the deadline as 04/15 which is accurate.

Logic 2
 
Date initialDate = Complaint_Receive__c;
	Date initialDatePlus = Complaint_Receive__c.addDays(1);
	Datetime datetime = datetime.newInstance(initialDate.year(), initialDate.month(),initialDate.day());
	Datetime deadline = BusinessHours.addGmt (stdBusinessHours.id, datetime, 10 * 23 * 60 * 60 * 1000L);

The only difference is adding one day to the complaint received date and used 23 hours in addGmt method instead of 24.

​​​​​​​To me Salesforce should return the deadline as 04/15 for Logic 1 itself. Please explain what I am missing here.

Note - Interestingly the Logic 1 is working  for some of the date but not all.
  • April 25, 2019
  • Like
  • 0
Hi,

I need to convert and assign 24 hours date time value to custom date time field.
For Example, in my apex code I am getting the date time value as ‘2019-03-12 14:38:00’, I need to convert and assign this value to custom date time field as 2019-03-12 02:38 PM in the Salesforce UI.
The format methods that I used so far converts '2019-03-12 14:38:00' to
'2019-03-12 10:38 AM' which is my user time zone.
 
I am not looking for time zone conversion, just format the date time.

Thanks,
Indrasen
  • March 20, 2019
  • Like
  • 0
We are using the platform events to deliver the custom lead notifications through apex class.
Database.SaveResult result = Eventbus.publish(leads);
When the user clicks on the notification message, Salesforce opens the Lead record in the new tab. How can we change this behavior to open the lead on the existing tab that the user is already working on.
  • February 13, 2019
  • Like
  • 0
Hi Team,
Is there a way to Hide/Disable reassign button in Approval History related list. In my scenario, I am assigning the approval request to different queues, Now Users of that particular queue are using the reassign button along with Approve/Reject.

Is there a way to disable the reassign button or any any custom solution(apex trigger) that can stop the user performing the reassign?

Thanks in advace.
Indy
  • September 15, 2018
  • Like
  • 0
My site guest user needs access for all the contacts in the instance. Right now site guest users can access contacts created by guest user. They are not able to access contacts created by Salesforce users. OWD setting for Contact is Public Read/Write. I don't want to change the OWD at this moment.
  • June 14, 2018
  • Like
  • 0
SFDC folks – I have a question and need all your inputs on migrating Salesforce compoents(fields, Record types and pick list values…) associated to Profiles in the source org to target org though ANT migration tool/Change sets.
If I include 10 fields and 3 profiles(Profile 1, Profile 2 and Profil 3 – Assume all the 3 profiles exists in target org) , Will migration tool modifies only the 10 fields and field level security settings associated with 3 profiles included in the package.xml or will it override the Profiles in the target org irrespective of fields mentioned in the package.xml in the target org?.

Also there was a saying that do not include the Profiles in any of the migration tool(ANT or Changes set) and perform all the field level security settings manually in target org after deployment. Is it is true statement. ?

My thought is we can very well include the profiles in package.xml, otherwise it will be a tedious work to enable the pemissions if the fields are more.

Please clarify the above questions.

Thanks,
Indy  
 
  • August 27, 2016
  • Like
  • 0
Hi All – We are facing network proxy issue in ODC when connecting to Salesforce from any client application like Data loader, Eclipse and ANT migration tool.

Error message from Data loader and ANT:
1. Failed to send request to https://test.salesforce.com/services/Soap/c/36.0

Eclipse error messages:
1.    Unable to find a valid path to requested target. – (When downloading new SFDC project).
2.    sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException  - ( When running integration from java)

Tried the below solutions so far but none of them works:
1.    Downloaded the Salesforce certificate from https://test.salesforce.com/services/Soap/c/36.0   and imported into java security cacerts.  (jre\lib\security\cacerts)
2.    Downloaded the latest data loader from Salesforce.
3.    Swapped different IP address in LAN settings.
4.    Tested by swapping the eclipse network connection types Manual, Native and Direct.

Please let me know the solution for this problem.

Thanks,
Indrasen
 
  • June 06, 2016
  • Like
  • 0
Hi All,
Please clarify my question on Time based workflow rules.

I have created a workflow rule on Opportunity with criteria ‘Application_Received_date__c = TODAY – 14’ (Intention is to check if the application was received 14 days ago then after 0 hours , create task and send email notification)

My assumption is that salesforce will check all the Opportunity records every day (without user interaction) and fire the workflow on a particular day that meets the above criteria.

But it is not working as expected. In order to really fire the workflow user has to go to edit a particular opportunity record to meet the criteria.

Please suggest the solution.
  • August 25, 2014
  • Like
  • 0
I created a time based workflow with criteria 'custom_date_field__c' = TODAY – 14.
But the workflow is firing only for newly created records which satisfy the above criteria. It is not firing for the existing records which suppose to trigger on a particular day.

Salesforce documentation says - User need not updated the existing records in order to fire the time based workflow.
Please help me to resolve the issue.

Thanks,
Indy
  • August 22, 2014
  • Like
  • 0
Hi,

How to reference static resource in  list button.

i.e My js file in Static Resource contains: (Static Resource is saved as 'LiquidatedAccounts')
<script>
{!REQUIRESCRIPT('/soap/ajax/25.0/connection.js')}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}


function liquidatedAccount()
{
var acc=true;
return acc;
}

</script>


In my list buttton(Execute Java script behaviour) , I am calling the liquidatedAccount() method in the following way and getting an error message says 'liquidatedAccount' is not recognized, Please suggest.

{!REQUIRESCRIPT('/soap/ajax/25.0/connection.js')}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
{!REQUIRESCRIPT("/resource/1392210043000/LiquidatedAccounts")}

var test1 = liquidatedAccount();
alert(test1);



Thanks,
Indy
  • February 12, 2014
  • Like
  • 0

Hi All,

 

I am trying to create new opportunity from Account using  ‘Salesforce URL hacking to Prepopulate fields’.

 I can able to populate most of the fields except owner. 

 

Here I am dynamically getting the ownerId and passing to URL. On my final opportunity edit page the owner value is logged in user instead of the owner that I am passing.

 

Any help is greatly appreciated.

 

Here is my url:

------------------------

 

// adds the proper code for inclusion of AJAX toolkit 
{!REQUIRESCRIPT('/soap/ajax/25.0/connection.js')}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}

 

var ownerId = sforce.apex.execute("HelperClassxxx","Methodxxx",param);

 

var newUrl = "/006/e?opp4_lkid={!Account.Id}&retURL=/{!Account.Id}&opp3={!Account.Name} &newOwn_lkid="+ownerId+"&newOwn=Indu cts";

 

window.parent.location.replace(newUrl);

 

 

Thanks,

Indy

  • December 11, 2013
  • Like
  • 0

Hi,

 

If I execute the below java code, The Http Response in debug log is:

 

Http Response****HTTP/1.1 415 Unsupported Media Type [Date: Tue, 03 Sep 2013 09:36:54 GMT, Content-Type: application/json;charset=UTF-8, Transfer-Encoding: chunked]

 

Can somebody please look into that and suggest the solution.

 

Java client application:
===============================================================================================================================
private static void updateAccount(String instanceUrl,String accToken) throws HttpException, UnsupportedEncodingException
{

List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("pdnNo", "14785"));
HttpPost post1 = new HttpPost(instanceUrl+"/services/data/v28.0/sobjects/Account/");
post1.setHeader("Authorization", "OAuth " + accToken);
post1.setHeader("content-type","text/html");
post1.setEntity(new UrlEncodedFormEntity(urlParameters,HTTP.UTF_8));

List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("pdnNo", "14785"));

try
{
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse httpResponse = client.execute(post1);
System.out.println("Http Response****"+httpResponse);
Map<String,String> updResponse = (Map<String,String>)JSONValue.parse(EntityUtils.toString(httpResponse.getEntity()));
for(Map.Entry<String, String> entry: updResponse.entrySet())
{
System.out.println(String.format("%s = %s",entry.getKey(),entry.getValue()));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}


Saleforce apex Rest:
======================================================================================================================
@RestResource(urlMapping='/Account/*')
global class AF_IB_Integration
{
@HttpGet
global static Account getAccount()
{
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.subString(req.requestURI.lastIndexOf('/')+1);
Account accRes = [Select Id,Name,Phone,WebSite FROM Account where id = :accountId limit 1];
return accRes;
}
@HttpPost
global static void updateAccount(String pdnNo)
{
if(pdnNo != null)
{
Account accRes = [Select Id,Primary_Dealer_Number__c,Type from Account Where Primary_Dealer_Number__c = :pdnNo];
accRes.Type= 'Integration';
update accRes;
}
}
}

  • September 03, 2013
  • Like
  • 0

Hi All,

I am writing the follwoing standard alone java code to connect salesforce. My intention is to get data from oracle data base and update sdfc data. Using OAuth authentication.

 

import java.io.IOException;
import java.net.CookiePolicy;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;

import com.sforce.ws.ConnectorConfig;

/*
Java client application to connect to IW database.
This client application uses Oauth as a Authentication mechanism.
*/
public class AF_IW_Integration 
{

private static final String redirectURL = "resttest:callback";
public static void main(String[] args) throws IOException
{
System.setProperty("proxyHost","xxxxxx");
System.setProperty("proxyPort","xxxxxxx");
HttpPost post = new HttpPost("https://cs11.salesforce.com/services/oauth2/token");

HttpClient client = new DefaultHttpClient();

List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("client_id","xxxxxx"));
params.add(new BasicNameValuePair("client_secret","xxxxxxxx"));
params.add(new BasicNameValuePair("username","usernam"));
params.add(new BasicNameValuePair("password","pass+token"));
//params.add(new BasicNameValuePair("redirect_uri",redirectURL));
params.add(new BasicNameValuePair("grant_type","password"));

post.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
ResponseHandler<String> responseHandler = new BasicResponseHandler();

HttpEntity httpEntity = null;
System.out.println("Post Base URL***"+post);
try
{

String response = client.execute(post,responseHandler);
System.out.println("Http Response***"+response);
}
finally
{

}
}
}

 

 

When I try to execute the below code...I am getting the error message....

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

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to https://cs11.salesforce.com refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1138)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1076)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1050)
at AF_IW_Integration.main(AF_IW_Integration.java:56)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:414)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
... 8 more

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

 

The proxy settings are correct. Also I can able to run the below code without any issues.

 

public static void main(String[] args) {

ConnectorConfig config = new ConnectorConfig();
config.setUsername(USERNAME);
config.setPassword(PASSWORD);
config.setProxy("proxy.cognizant.com", 6050);
config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/26.0");
try {

// connect to the salesforce instance
connection = Connector.newConnection(config);

// display some current settings
System.out.println("Auth EndPoint: " + config.getAuthEndpoint());
System.out.println("Service EndPoint: " + config.getServiceEndpoint());
System.out.println("Username: " + config.getUsername());
System.out.println("SessionId: " +config.getSessionId());

}

 

Any help is greatly appreciated.

 

 

Thanks,

Indy.

  • August 30, 2013
  • Like
  • 0

Hi,

I am force.com developer and new to Integration. Currently we have standard alone java application which is used to connect Oracle database to update salesforce data. Currently we have hard coded the credentials in java program.

 

 - What is best approach for programmatic (Java) Integration? SOAP or REST? (The volume of data is huge.) 

 - What is best authentication approach to avoid hard coding the credentials in the application?

 

As per my knowledge Oauth will work only for web applications.

 

Kindly clarify the above questions and also suggest the resources that gives good understanding in SOAP, Rest ,Oauth....

 

Thanks in advance.

 

- Indy.

  • August 23, 2013
  • Like
  • 0

Hi,

 

I am in the process of developing client application using java by going through the link

http://wiki.developerforce.com/page/Introduction_to_the_Force.com_Web_Services_Connector

 

 

But ended with the error message. Please help.

 

Input:

 

D:\Sfdc Practice>java -classpath wsc-22-jdk-1.7.jar com.sforce.ws.tools.wsdlc enterprisewsdl.wsdl enterprise.jar

 

Output:

 

[WSC][wsdlc.run:312]Created temp dir: C:\Users\371278\AppData\Local\Temp\wsdlc-t
emp-5760672496630946977-dir
Exception in thread "main" com.sforce.ws.wsdl.WsdlParseException: Parse error: enterprisewsdl.wsdl (The system cannot find the file specified)
at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:61)
at com.sforce.ws.tools.wsdlc.<init>(wsdlc.java:75)
at com.sforce.ws.tools.wsdlc.run(wsdlc.java:312)
at com.sforce.ws.tools.wsdlc.main(wsdlc.java:303)
Caused by: java.io.FileNotFoundException: enterprisewsdl.wsdl (The system cannot
find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:58)
... 3 more

 

 

Thanks,

Indy

  • May 07, 2013
  • Like
  • 0

Hi Friends,

 

My requirement is to create xml initially and append (update) the xml over a period of time.

 

When customer signed a contract, the contract details are appended to text area field in the form of below xml.

i.e 

<?xml version="1.0" encoding="UTF-8"?>

<Contracts>

     <Contract ContractID="Original Contract" StartDate="2011-03-07" EndDate="2012-12-31">

          <ContractRecord TYPE="Silver" AccessoriesIncluded="true" AccessoriesNotes="test notes..."></ContractRecord>

     </Contract>

</Contracts>

 

Once the contract gets expired (End Date reaches), customer will renew the contract then the xml format would be the original contract plus renew contract.

 

<?xml version="1.0" encoding="UTF-8"?>

     <Contracts>

              <Contract ContractID="Original Contract" StartDate="2011-03-07" EndDate="2012-12-31">

                    <ContractRecord TYPE="Silver" AccessoriesIncluded="true" AccessoriesNotes="test notes...">

                    </ContractRecord>

               </Contract>

             

              <Contract ContractID="Renew Contract" StartDate="2013-01-01" EndDate="2014-12-31">

                       <ContractRecord TYPE="Silver" AccessoriesIncluded="true" AccessoriesNotes="test notes...">

                       </ContractRecord>

               </Contract>

       </Contracts>

 

I can achieve the 'Original Contract' xml creation using xmlStreamWriter class. The concern is how to append

  the 'Renew Contract' to the original contract.

 

The two options I am aware of:

 

1.    Read each xml element of original contract and write to a new xml stream writer and append the                                                        

       current renew tag elements and close the parent element. (i.e. </Contracts>)

 

2.  Read each xml element of original contract and populate the data to a wrapper class, then create a new  xml stream  

     writer  and append the original contract elements from wrapper class and current contract renewal elements and

     close the parent element(</Contracts>).

 

As I am processing large data volume, I need a better (Optimize) way to append the renew contract details to original contract.

 

Your immediate response is highly appreciated.

 

Note:  Is there a way to read the end element (</Contracts>) and append the new contract details and close the end element.

 

Thanks,

Indy

 

  • August 11, 2012
  • Like
  • 0

Hi All,

 

I am generating a PDF document by clicking the button on SObject. But the requirement was to print that document automatically whenever there is a change in objects attribute value.

 

For Ex: If order status = 'Completed' then print the document.

 

Please suggest is there a way to achieve this by using Apex code or any API.

Or Is it possible with Workflow outbound message ?.

 

If not possible by coding kindly suggest any AppExchange App.

 

 

Thanks in advance.

 

--Indy

  • February 29, 2012
  • Like
  • 0
I am not able to show the custom validation error message as a result of  callback method.

Controller.js
saveCase : function(component, event, helper){
       //existing validations...
       var validTab1 = helper.validateTab1(component); 
       var validTab2 = helper.validateTab2(component); 
       
        //New validaiotn      
        var isValidDate =           helper.validateExtDate(component);
        // Other business validations....
        helper.createCase(compoent);

}


Helper.js
 
validateExtDate:function(component)
{
    var caseRec = component.get("v.case");
    var action = component.get("c.getResponseDeadlineOnEdit");
    action.setParams({
                                "cs":caseRec
    });

    action.setCallback(this,function(response){
             this.processresults(response, component);
    });
    $A.enqueueAction(action);
},

processresults : function(response,component) {
    var extnsDate = component.find("respExtdate");
    var extnsDateVal = extnsDate.get("v.value");
    var extDate = new Date(extnsDateVal);

    var state = response.getState();
    if(state === "SUCCESS") {
         var deadlinedate= response.getReturnValue();      
         if(extDate <=  deadlineDate) {
                    extnsDate.set("v.errors", [{message: "Please select a different date” }]);
        }
}

The contoller.js is executing all the helper methods including the new asynch/callback method in helper.  But it is not stopping the flow if the custom validation occurs. i.e Due to asynch behaviour the flow is executing the existing createCase method, which save the case even if there is a validation. 
  • July 19, 2019
  • Like
  • 0
We are using the platform events to deliver the custom lead notifications through apex class.
Database.SaveResult result = Eventbus.publish(leads);
When the user clicks on the notification message, Salesforce opens the Lead record in the new tab. How can we change this behavior to open the lead on the existing tab that the user is already working on.
  • February 13, 2019
  • Like
  • 0
Hi Team,
Is there a way to Hide/Disable reassign button in Approval History related list. In my scenario, I am assigning the approval request to different queues, Now Users of that particular queue are using the reassign button along with Approve/Reject.

Is there a way to disable the reassign button or any any custom solution(apex trigger) that can stop the user performing the reassign?

Thanks in advace.
Indy
  • September 15, 2018
  • Like
  • 0
The following value is my input
'11/21/2014 15:20:00'
i want to change the above value format like '11/21/2014 03:20 pm'
how to do this any help me

i am getting errors like this "System.TypeException: Invalid date/time: 11/21/2014 15:20:00"
Hi All,
Please clarify my question on Time based workflow rules.

I have created a workflow rule on Opportunity with criteria ‘Application_Received_date__c = TODAY – 14’ (Intention is to check if the application was received 14 days ago then after 0 hours , create task and send email notification)

My assumption is that salesforce will check all the Opportunity records every day (without user interaction) and fire the workflow on a particular day that meets the above criteria.

But it is not working as expected. In order to really fire the workflow user has to go to edit a particular opportunity record to meet the criteria.

Please suggest the solution.
  • August 25, 2014
  • Like
  • 0
I created a time based workflow with criteria 'custom_date_field__c' = TODAY – 14.
But the workflow is firing only for newly created records which satisfy the above criteria. It is not firing for the existing records which suppose to trigger on a particular day.

Salesforce documentation says - User need not updated the existing records in order to fire the time based workflow.
Please help me to resolve the issue.

Thanks,
Indy
  • August 22, 2014
  • Like
  • 0

Hi,

I have a requirement to update the current ActorId from the approval Process to the target object record. I am able to do this for initial submission, approval and rejection actions using workflow and triggers leveraging the trigger execution flow. 

I have to update the ActorId on the TargetObject record even when a process is Reassigned from one user to another. As, we do not have reassignment actions, is there any possibility apart from batch class that I can achieve this?

Thank You in Advance for your help!!

Regards,
Sravan.

Apex Trigger on Reassign Approvals,

I have created an Add error on if the users try and reassign to a different approver. The code however doesnt seem to fire on reassign. I thought that If i said that the orginalActorid deosnt match the Actorid then fire a adderror when clicked.

Then I thought that if steps = reassigned value then through error but it doesnt fire either. Any help would be great. i would rather not create a VF but i guess i could try if this is not possible.

trigger ADRUserReassign on ADRUser__c (after update) {
 

public String ADendid;

       list<ADRUser__c> ad =[Select id, Name, User__c from ADRUser__c where id =:ADendid];
        list<ADRUser__c> ad2Update = new list<ADRUser__c>();
        map<id, ADRUser__c> ADaddMap = new map<id, ADRUser__c>([Select id from ADRUser__c where id =:ADendid]);
        list<ProcessInstance> PI = new list<ProcessInstance>();
        map<id, id> PIVaddMap = new map<id, id>();
       
        system.debug(' ID Value on Target Object ' + ADaddMap);
                       
      
        for (ProcessInstance lstProcess : [Select id, Status, CreatedDate, TargetObjectId,
                                    (Select Id,ProcessInstanceId, StepStatus,
                                        Comments,OriginalActorId,ActorId
                                    From steps order by CreatedDate DESC)
                                From ProcessInstance 
                                where targetobjectid=:ADendid order by CreatedDate DESC]){
            PI.add(lstProcess);
            PIVaddMap.put(lstProcess.TargetObjectId, lstProcess.id);
           
            }
       
   
      
        for(ProcessInstance lstPI :  PI){
     //  if(lstPI.Status=='Reassigned'){
        for(ProcessInstanceStep lstSteps : lstPI.Steps){
    //    if(lstSteps.OriginalActorId != lstSteps.ActorId){
            if(lstSteps.StepStatus == 'Reassigned'){
     lstPI.addError('You cannot reassign - try again');
    id ADRUserAddId = PIVaddMap.get(lstPI.TargetObjectId);
       ADRUser__c AAdd =  ADaddMap.get(lstPI.TargetObjectId);
       lstPI.addError('You cannot reassign - try again');
//         if (lstSteps.OriginalActorId != lstSteps.ActorId){

//  lstSteps.addError('You cannot reassign - try again');
        }
            }
                }
                }
     //           }
              //  } //End void
//}//End main
Hi,

How to reference static resource in  list button.

i.e My js file in Static Resource contains: (Static Resource is saved as 'LiquidatedAccounts')
<script>
{!REQUIRESCRIPT('/soap/ajax/25.0/connection.js')}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}


function liquidatedAccount()
{
var acc=true;
return acc;
}

</script>


In my list buttton(Execute Java script behaviour) , I am calling the liquidatedAccount() method in the following way and getting an error message says 'liquidatedAccount' is not recognized, Please suggest.

{!REQUIRESCRIPT('/soap/ajax/25.0/connection.js')}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
{!REQUIRESCRIPT("/resource/1392210043000/LiquidatedAccounts")}

var test1 = liquidatedAccount();
alert(test1);



Thanks,
Indy
  • February 12, 2014
  • Like
  • 0

Hi All,

I am writing the follwoing standard alone java code to connect salesforce. My intention is to get data from oracle data base and update sdfc data. Using OAuth authentication.

 

import java.io.IOException;
import java.net.CookiePolicy;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;

import com.sforce.ws.ConnectorConfig;

/*
Java client application to connect to IW database.
This client application uses Oauth as a Authentication mechanism.
*/
public class AF_IW_Integration 
{

private static final String redirectURL = "resttest:callback";
public static void main(String[] args) throws IOException
{
System.setProperty("proxyHost","xxxxxx");
System.setProperty("proxyPort","xxxxxxx");
HttpPost post = new HttpPost("https://cs11.salesforce.com/services/oauth2/token");

HttpClient client = new DefaultHttpClient();

List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("client_id","xxxxxx"));
params.add(new BasicNameValuePair("client_secret","xxxxxxxx"));
params.add(new BasicNameValuePair("username","usernam"));
params.add(new BasicNameValuePair("password","pass+token"));
//params.add(new BasicNameValuePair("redirect_uri",redirectURL));
params.add(new BasicNameValuePair("grant_type","password"));

post.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
ResponseHandler<String> responseHandler = new BasicResponseHandler();

HttpEntity httpEntity = null;
System.out.println("Post Base URL***"+post);
try
{

String response = client.execute(post,responseHandler);
System.out.println("Http Response***"+response);
}
finally
{

}
}
}

 

 

When I try to execute the below code...I am getting the error message....

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

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to https://cs11.salesforce.com refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1138)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1076)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1050)
at AF_IW_Integration.main(AF_IW_Integration.java:56)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:414)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
... 8 more

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

 

The proxy settings are correct. Also I can able to run the below code without any issues.

 

public static void main(String[] args) {

ConnectorConfig config = new ConnectorConfig();
config.setUsername(USERNAME);
config.setPassword(PASSWORD);
config.setProxy("proxy.cognizant.com", 6050);
config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/26.0");
try {

// connect to the salesforce instance
connection = Connector.newConnection(config);

// display some current settings
System.out.println("Auth EndPoint: " + config.getAuthEndpoint());
System.out.println("Service EndPoint: " + config.getServiceEndpoint());
System.out.println("Username: " + config.getUsername());
System.out.println("SessionId: " +config.getSessionId());

}

 

Any help is greatly appreciated.

 

 

Thanks,

Indy.

  • August 30, 2013
  • Like
  • 0

Hi,

I am force.com developer and new to Integration. Currently we have standard alone java application which is used to connect Oracle database to update salesforce data. Currently we have hard coded the credentials in java program.

 

 - What is best approach for programmatic (Java) Integration? SOAP or REST? (The volume of data is huge.) 

 - What is best authentication approach to avoid hard coding the credentials in the application?

 

As per my knowledge Oauth will work only for web applications.

 

Kindly clarify the above questions and also suggest the resources that gives good understanding in SOAP, Rest ,Oauth....

 

Thanks in advance.

 

- Indy.

  • August 23, 2013
  • Like
  • 0

i am trying to connect to salesforce using post to get instance url and token..

but i am getting this error ...

how should i resolve this ??

i have also gicen proxy manually...

 

 

org.apache.http.conn.HttpHostConnectException: Connection to https://login.salesforce.com refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.sample.onpremise.ChatterIntegration.login2ForceDotCom(ChatterIntegration.java:70)
at com.sample.onpremise.ChatterIntegration.main(ChatterIntegration.java:39)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:375)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
... 9 more

Hi,

 

I am in the process of developing client application using java by going through the link

http://wiki.developerforce.com/page/Introduction_to_the_Force.com_Web_Services_Connector

 

 

But ended with the error message. Please help.

 

Input:

 

D:\Sfdc Practice>java -classpath wsc-22-jdk-1.7.jar com.sforce.ws.tools.wsdlc enterprisewsdl.wsdl enterprise.jar

 

Output:

 

[WSC][wsdlc.run:312]Created temp dir: C:\Users\371278\AppData\Local\Temp\wsdlc-t
emp-5760672496630946977-dir
Exception in thread "main" com.sforce.ws.wsdl.WsdlParseException: Parse error: enterprisewsdl.wsdl (The system cannot find the file specified)
at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:61)
at com.sforce.ws.tools.wsdlc.<init>(wsdlc.java:75)
at com.sforce.ws.tools.wsdlc.run(wsdlc.java:312)
at com.sforce.ws.tools.wsdlc.main(wsdlc.java:303)
Caused by: java.io.FileNotFoundException: enterprisewsdl.wsdl (The system cannot
find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:58)
... 3 more

 

 

Thanks,

Indy

  • May 07, 2013
  • Like
  • 0

I need to create an event whenever Opportunity field Probability is greater than 50%

 

I have written the code but it keeps firing on every update.I want it to fire on an insert or if there is any change in probability

 

My code is 

 

********************************

 

trigger AutoEventCreate on Opportunity (after insert , after update) {

List <Event> eventList = new List <Event> ();
Set<Id> oppIds = new Set<Id>();
for(Opportunity opp:Trigger.new){
if(opp.Id!=null &&(Trigger.isInsert || (Trigger.newMap.get(opp.id).Probability != Trigger.oldMap.get(opp.Id).Probability))){

oppIds.add(opp.Id);
}

}

for(Opportunity opp:Trigger.new){
if(opp.Probability !=null && opp.Probability>=25.00){

datetime myDate = datetime.now();



eventList.add (new Event(
Subject = 'Other',
WhatId = opp.Id,
OwnerId = opp.OwnerId,
StartDateTime = DateTime.Now(),
ActivityDateTime=null,
EndDateTime = DateTime.Now(),
DurationInMinutes = Integer.valueOf(Math.Floor( (myDate.getTime() - myDate.getTime()) / (1000.0*60.0)))

));

}
if(eventList.size() > 0)

insert eventList;

}

}

 

 

***************************

 

Can you please correct y code and let me know if any scenarios need to be added

 

Thanks in advance

Folks,

 

 

If you try using the isempty() function similar to the list and set methods  for strings then it will throw an error.

Instead use the below syntax

 

String st = 'Hello'; 
Boolean val= String.isEmpty(st);

 

 

Thanks,
Rakesh B

 

Hi All,

 

I am generating a PDF document by clicking the button on SObject. But the requirement was to print that document automatically whenever there is a change in objects attribute value.

 

For Ex: If order status = 'Completed' then print the document.

 

Please suggest is there a way to achieve this by using Apex code or any API.

Or Is it possible with Workflow outbound message ?.

 

If not possible by coding kindly suggest any AppExchange App.

 

 

Thanks in advance.

 

--Indy

  • February 29, 2012
  • Like
  • 0

Hi All,

While creating a product( lookup) filed in my custom object,The lookup filter option is not available.

Can some one please help how to enable that.

 

Thanks,

Indy

  • April 06, 2011
  • Like
  • 0

Hello All,

 

I need to send an uploaded document to a third party webservice. I can send text files fine. But all other file types are getting corrupted.

I have been struggling for the past 3 weeks with this problem . I ahve tried several variations like Content-Transfer-Encoding : base64 and sending the

EncodingUtil.base64Encode(blob) with no luck. Is there some thing I am missing. I need to be ableto send pdfs, images, doc files.

Please help.

 

Thanks

Gopi

String response; String boundary = 'AaBbCcX30'; String m_URL = 'some url'; String content = 'Content:\r\n--' + boundary + '\r\nContent-Disposition:form-data;name="' + p_fileName + '";filename="'+p_fileName+'"\r\n'; content +='Content-Type:' + p_fileContentType + ',charset=ISO-8859-1,*,utf-8\r\n'; content +='Content-Transfer-Encoding: binary\r\n\r\n'; content += p_fileBlob +'\r\n\r\n'; content += '--'+boundary+'--\r\n'; System.debug(p_fileBlob.size()+'content ' + content); Http m_http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(m_URL); req.setHeader('Content-Type','multipart/form-data;boundary='+boundary); req.setMethod('POST'); req.setBody(content); HttpResponse m_httpResp = null; m_httpResp = m_http.send(req); m_strHttpResp = m_httpResp.getBody();

 

  • March 09, 2009
  • Like
  • 0