• Sidharth
  • NEWBIE
  • 329 Points
  • Member since 2011

  • Chatter
    Feed
  • 12
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 64
    Questions
  • 132
    Replies

I am working on trying to develop a class to display just the attachments on our Salesforce Instance.  Kind of like the Attachment Manager that is available.  However, I will be having it displayed in a VisualForce Page.  Trying to query from the Database, but unsure of how to get the informaiton from all the attachments, not just related to a single case.  Any ideas?

Hi 

 

 In sandbox i am want to deactivate an apex class, i am not seeing the status checkbox when i click edit link of the class. Is this normal? Is there any other way in which in can deactivate the classes?

 

Thanks

  • February 08, 2012
  • Like
  • 0

 

Hi guys,

 

 

@isTest
private with sharing class Loan
{
    static testMethod void Loan()
    {
        Test.startTest();
        
// set up account
        Account acc = new Account();
        acc.Name = 'Acme Account Test';
        acc.Account_Type__c= 'Audio';
        acc.Strategic_Segmentation__c= 'C - Small';
        acc.Country__c= 'Spain';
        insert acc;
        
        List<Contract> lstContract= new List<Contract>();
        for(Integer iCount = 0; iCount < 20; iCount++)
        {
            Contract objContr = new Contract();
            objContr.Account= acc.id;
            objContr.StartDate= Date.today();
            objContr.ContractTerm= '11111';
            objContr.CurrencyIsoCode= 'EUR';
            objContr.Status= 'Borrador';

            lstContract.Add(objContr);
        }
        insert lstContract;
        Test.StopTest();
    }
}

 

Error: Compile Error: Illegal assignment from Id to SOBJECT:Account at line 20 column 13

 

Any ideas??

  • November 08, 2011
  • Like
  • 0
I have apex batch scheduled to run daily.This batch query sometime timesout (First error: [QUERY_TIMEOUT] Your query request was running for too long).

Is there any wayto retry the batch at the same time ?

The problem is, this type of error, doesnot go in the try/catch, and also no FInish method is called. So i am not sure how to detect this batch failure and rerun it. 

Sid
1. Is there anyway to capture HTTP response time in apex ? 
2. Is there anyway to see long running calls in SF ? Seems there is a limit of 25.
Can we open a HTML Email template as pdf using Custom link/button, so user can print/save the document.
Hello,

Account_Review__c has three picklist fields, and there are dependency rules defined between them, so options for one field, depends on whats selected in the other.

I am tryign to display the values of these three fields, in a pageblock. But its causing multiple rerenders, because of dependency picklists, and therefore showing wrong results.

Ex. I set values in three fields, and then if i change the first picklist value, the values in second and third picklist shows NULL (per dependency rules) in the dropdown, but doesnt show NULL when i am printing in the page block. See attached images.

What should i do so the values in pageblock, alwasy show the correct picklist values, after rerender. Thanks.
<apex:page standardController="Account_Review__c">

    <apex:form>
        <apex:pageBlock>
            <apex:inputfield value="{!Account_Review__c.Reason__c}" id="f1">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
            <apex:inputfield value="{!Account_Review__c.Result__c}" id="f2">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
            <apex:inputfield value="{!Account_Review__c.Action__c}" id="f3">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
        </apex:pageBlock>
        
        <apex:pageBlock id="Block1">
            <apex:outputLabel >{!Account_Review__c.Reason__c}</apex:outputLabel><BR/>
            <apex:outputLabel >{!Account_Review__c.Result__c}</apex:outputLabel><BR/>
            <apex:outputLabel >{!Account_Review__c.Action__c}</apex:outputLabel><BR/>
        </apex:pageBlock>
    </apex:form>

</apex:page>
User-added imageUser-added image
 
Can anybody share the C# bulk (query, insert, update, delete) api examples. Online i can find Java exaples, but not C#.

-Sid
Hello All,

Does anybody have sample Java code to Bulk query SF records followed by Bulk delete in the same call ?

Thanks
Sid
What different ways can we hard delete salesforce records.

1. From within Apex (batch) ?
2. Bulk API (Java) ? 
3. Data loader - Hard Delete options ? Tried this, working fine.

Out requirements is to have a batch running every X minutes (inside/outide of SF) which can query records and hard delete them.

-Sid
Hi All,

Is there a way in Apex to see if the specified text passes the salesforce password policies. 

Use Case: In our customer portal, we are allowing new users to register for the portal. So we are inserting a new user and setting the password in the same call. Now if the password doesnt pass the password policies, than the user is created in sf, but the password is not set. (we are not using temporary password approach)

Thanks
Sid
Is there a way to parse just the exception code while making calls like insert user, System.setPassword etc.

The error message show: 
Insert failed. First exception on row 0; first error: PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT, portal user already exists for contact: []
Failure : INVALID_NEW_PASSWORD: Your password must be at least 5 characters long.

But now sure how to just get PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT , INVALID_NEW_PASSWORD

List of exception codes: https://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm#i1421192
Is there a way to login another user in the apex class, to get the session id of that user. I probably can do it using the soap Login call within apex, passing username and password for the second user, and get the session id. But wondering if there is a shortcut for the same.

Thanks.
Sid
<apex:iframe src="data:application/pdf;base64,{!BankStatement}"/>
rendering the pdf correctly in Chrome and Mozilla, but showing blank in IE. 

{!BankStatement} is the encoded pdf, we are getting from a http call. 
Hi, my company is building a customer portal, outside of salesforce (i.e. not using native SF sites).
How can i authenticate the portal users, for example in a java application, using REST. I can do it using SOAP by using company partner wsdl.
Any help will be appreciated.

Thanks
Sid 
Hello,

How do we authenticate a portal user via a completely external site?  

-Sid
Hello All,

Is there any way we can get the custom settings values in custom button code ?

Thanks
Sid
Hi,

What will be the cron expression to schedule a batch to run :

Every 1 Hour + Every Day + 11AM - 6PM

Thanks
Sid
Hi All,

If i make a change in apex class in Force.Com ide (installed as a plugin in Eclipse Kepler), it doesnt not check the server file, and overrites it, even if the server file is different.
I expect, IDE should throw the error - file doesnt match the server file, and should fail to update. Not sure why its happening, any ideas ?

Thanks
Sid
Hello All,

We have a outside application, which is suppose to update couple records in SF.
Now these records can hit Validation Rule, which prevents the records to save successfully.
Can we have some error traping on these records updates coming from outside of SF, so if they hit the Validation Rule, than shoot an email notification to the admin.
I can read these updates in the Before Trigger, but not sure how to actually catch if they fail to save.
Any help is appreciated.

Thanks
Sid
Hello All,

I have a requirement to add checkboxes(options) in a javascript alert box prompted on click of a custom button (on standard layout) using execute javascript.
So the flow should be , a user clicks the custom button, it should pop a alert box with multiple checkbox options, where the user can select one or more options, which should be returned back to the button code for further processing.
I am stuck on adding checkboxes in to the alert box. 
Any trick to achive this ?

Thanks
Sid
Hi,

Is there any way to get description of all fields of an object in apex code?
Able to query inline text help, label, api name, length etc, but not the description.
Any workaround/trick ?

Thanks
Sid
Hi,

I have a requirement to display/provide download link to the http blob response in visualforce page.
I am able to create a new attachment/document from blob value and provide a download link to that in vf page using {!URLFOR($Action.Attachment.Download,ReportName)}".
But i dont want to create a new attachemnt, just pass it from apex to vf page.
Any ideas ?

Thanks
Sid
Hello,

Account_Review__c has three picklist fields, and there are dependency rules defined between them, so options for one field, depends on whats selected in the other.

I am tryign to display the values of these three fields, in a pageblock. But its causing multiple rerenders, because of dependency picklists, and therefore showing wrong results.

Ex. I set values in three fields, and then if i change the first picklist value, the values in second and third picklist shows NULL (per dependency rules) in the dropdown, but doesnt show NULL when i am printing in the page block. See attached images.

What should i do so the values in pageblock, alwasy show the correct picklist values, after rerender. Thanks.
<apex:page standardController="Account_Review__c">

    <apex:form>
        <apex:pageBlock>
            <apex:inputfield value="{!Account_Review__c.Reason__c}" id="f1">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
            <apex:inputfield value="{!Account_Review__c.Result__c}" id="f2">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
            <apex:inputfield value="{!Account_Review__c.Action__c}" id="f3">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
        </apex:pageBlock>
        
        <apex:pageBlock id="Block1">
            <apex:outputLabel >{!Account_Review__c.Reason__c}</apex:outputLabel><BR/>
            <apex:outputLabel >{!Account_Review__c.Result__c}</apex:outputLabel><BR/>
            <apex:outputLabel >{!Account_Review__c.Action__c}</apex:outputLabel><BR/>
        </apex:pageBlock>
    </apex:form>

</apex:page>
User-added imageUser-added image
 
What different ways can we hard delete salesforce records.

1. From within Apex (batch) ?
2. Bulk API (Java) ? 
3. Data loader - Hard Delete options ? Tried this, working fine.

Out requirements is to have a batch running every X minutes (inside/outide of SF) which can query records and hard delete them.

-Sid
Hi All,

Is there a way in Apex to see if the specified text passes the salesforce password policies. 

Use Case: In our customer portal, we are allowing new users to register for the portal. So we are inserting a new user and setting the password in the same call. Now if the password doesnt pass the password policies, than the user is created in sf, but the password is not set. (we are not using temporary password approach)

Thanks
Sid
Hi,

Is there any way to get description of all fields of an object in apex code?
Able to query inline text help, label, api name, length etc, but not the description.
Any workaround/trick ?

Thanks
Sid
Can we open a HTML Email template as pdf using Custom link/button, so user can print/save the document.
Hello,

Account_Review__c has three picklist fields, and there are dependency rules defined between them, so options for one field, depends on whats selected in the other.

I am tryign to display the values of these three fields, in a pageblock. But its causing multiple rerenders, because of dependency picklists, and therefore showing wrong results.

Ex. I set values in three fields, and then if i change the first picklist value, the values in second and third picklist shows NULL (per dependency rules) in the dropdown, but doesnt show NULL when i am printing in the page block. See attached images.

What should i do so the values in pageblock, alwasy show the correct picklist values, after rerender. Thanks.
<apex:page standardController="Account_Review__c">

    <apex:form>
        <apex:pageBlock>
            <apex:inputfield value="{!Account_Review__c.Reason__c}" id="f1">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
            <apex:inputfield value="{!Account_Review__c.Result__c}" id="f2">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
            <apex:inputfield value="{!Account_Review__c.Action__c}" id="f3">
                <apex:actionSupport event="onchange" reRender="Block1"/>
            </apex:inputField>
        </apex:pageBlock>
        
        <apex:pageBlock id="Block1">
            <apex:outputLabel >{!Account_Review__c.Reason__c}</apex:outputLabel><BR/>
            <apex:outputLabel >{!Account_Review__c.Result__c}</apex:outputLabel><BR/>
            <apex:outputLabel >{!Account_Review__c.Action__c}</apex:outputLabel><BR/>
        </apex:pageBlock>
    </apex:form>

</apex:page>
User-added imageUser-added image
 
Can anybody share the C# bulk (query, insert, update, delete) api examples. Online i can find Java exaples, but not C#.

-Sid
Hello All,

Does anybody have sample Java code to Bulk query SF records followed by Bulk delete in the same call ?

Thanks
Sid
What different ways can we hard delete salesforce records.

1. From within Apex (batch) ?
2. Bulk API (Java) ? 
3. Data loader - Hard Delete options ? Tried this, working fine.

Out requirements is to have a batch running every X minutes (inside/outide of SF) which can query records and hard delete them.

-Sid
Hi All,

Is there a way in Apex to see if the specified text passes the salesforce password policies. 

Use Case: In our customer portal, we are allowing new users to register for the portal. So we are inserting a new user and setting the password in the same call. Now if the password doesnt pass the password policies, than the user is created in sf, but the password is not set. (we are not using temporary password approach)

Thanks
Sid
Is there a way to parse just the exception code while making calls like insert user, System.setPassword etc.

The error message show: 
Insert failed. First exception on row 0; first error: PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT, portal user already exists for contact: []
Failure : INVALID_NEW_PASSWORD: Your password must be at least 5 characters long.

But now sure how to just get PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT , INVALID_NEW_PASSWORD

List of exception codes: https://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm#i1421192
Is there a way to login another user in the apex class, to get the session id of that user. I probably can do it using the soap Login call within apex, passing username and password for the second user, and get the session id. But wondering if there is a shortcut for the same.

Thanks.
Sid
Hi Everyone,

I am new to Salesforce coding and learning to integrate with Salesforce. I am facing issue as mentioned below.

Scenario - I am integrating two Salesforce instance using APEX Callout and REST API. In the source SFDC instance I have created a trigger on the Account Object that calls a class with @future annotation. This class sends out a HTTP Request to the other SFDC instance using Web Server Authentication Flow.

Issue Description - Per the defined steps in 'Getting Started with the Force.com REST API' guide, I create a Connected App record in the Destination SFDC instance. But when the APEX code is requesting the Salesforce Authorization Endpoint with the relevant parameters (response_type, client_id, redirect_uri), I am not able to retrieve the Authorization Code (Code) that comes along with the Callback URL.
Though, I am successfully redirected to the callback URL (appended with the code) when I am using a browser. See below the request and the redirected response I get when I do it in a browser - 
HTTP Request:
https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=[client_id taken from the Connected App record]&redirect_uri=https://localhost:8443/RestTest/oauth/_callback&immediate=true
HTTP Response:
http://localhost:8443/RestTest/oauth/_callback?code=[aPrxg.........]%3D%3D

Problem Statements - 
1. On the first place, is it possible to programmatically extract the code from the HTTP response?

2. If the answer to the above question is 'Yes', then please suggest, how? What are the relevant methods to extract this information.

Thanks
Anupam

Hi, I'm having some problems handling XML files with the Force WSC. First, an issue with unmarshalling CustomObject files:

com.sforce.ws.ConnectionException: UTF-8Not a valid enumeration for type: class com.sforce.soap.metadata.Encoding

 

I can see that the enumeration com.sforce.soap.metadata.Encoding is expecting "UTF_8" rather than "UTF-8", however the metadata is retrieved with the hyphen. Do I really have to find and replace this case before I can unmarshal the file properly? For the record, I used Force WSC to create these classes, Force WSC to retrieve the metadata, and I am using Force WSC to unmarshal the files. Is this framework incompatible with itself?

 

The issue with marshalling those CustomObject files is that I can't seem to save them in the same format that they were downloaded in. Whenever I marshall a metadata object to an XML file, it adds namespace prefixes ("n1:") to every tag, which is not how I want to store the data. So is there any way to marshal these files without the namespace prefixes, or will I have to do this myself after they are written?

 

Thanks in advance.

Hello,

        I need bulk api code in C#.net.The developer guide gives the code for client java application.I need it for C#.net.or can i convert the same code to C#.I tried it using IKVM,buit couldnot do it successfully.Please help.

Hi,

Can any one explain Bulk api with a small sample code.

I know bulk api is used for processing large amounts of data and is being used with apex data loader but what if some wants to impliment bulk api without the apex dataloader.

 

Please help with an example.

 

Thanks.

  • September 23, 2013
  • Like
  • 0

Hi Devs,

 

I want to connect with my localhost .for that i use "http:localhost:9000" in htpprequest in apex. It shows service unavailable error.

Apex is run in salesforce server ,so it doesnt any response to me.

 

Is there any other way to do this.

 

Please help regarding this.

 

 

//My Http request 

Http http  = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint('http://localhost:9000'); 
        req.setMethod('GET');
        req.setTimeout(50000);
        req.setbody(xmlStringxmlRD);
        HttpResponse res = http.send(req); 
        system.debug('&&&&res'+res);

 

my Debug log show as

 

&&&&resSystem.HttpResponse[Status=Service Unavailable, StatusCode=503]

 

 

Hi,

 

I'm using DescribeSObjectResult to retrieve details about Object and its fields.

I noted that the Description property of each field is not available. 

 

I see here

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describesobjects_describesobjectresult.htm#i1427375

 

Am I missing anything here?

 

What's the reason for not having the description available in API?

 

Thanks

Manuel