• Puneet Sardana
  • NEWBIE
  • 160 Points
  • Member since 2013

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 30
    Replies

How to query records from recycle bin?

Greetings,

 

I have a dependent picklist that I need some validation on.  When "Disqualified" or "Recycled" is selected from the controlling field, I want the dependent field to be required.  The dependent field is only editable when "Disqualified" or "Recycled" are selected.  I implemented some code in the "Save" function but it does not work.  I am very new to APEX so any help is greatly appreciated.  My code is as follows:

 

***************************************************CONTROLLER******************************************************

public class NewController {    

          public List<Account> myAccounts;        

              public Boolean isEditEnabled;        

 

public NewController(){        

      myAccounts = new List<Account>();                

                IsEditEnabled = false;    

}

 

public List<Account> getMyAccounts(){        

         myAccounts = [select Id,name,type, dq_reason__c,preferred_mode_s__c,micro_industry__c from Account WHERE (owner.id =: userinfo.getuserid())];                   

         return myAccounts;              

}           

public PageReference edit() {                

          isEditEnabled = true;                              

          return null;       

}    

public PageReference save() {                              

         for (account a: myaccounts){                

            if(a.type == 'Disqualified' || a.type == 'Recycled'){                    

                If(a.dq_reason__c == 'NULL'){                        

                  apexpages.addmessage(new apexpages.message(ApexPages.severity.ERROR,'Please enter a DQ reason'));                        

}                    

}                    

}                

          update myAccounts;                

          isEditEnabled = false;        

return null;       

}

public Boolean getIsEditEnabled(){                

        return isEditEnabled;        

}

}

 

 

*******************************************VISUALFORCE PAGE***********************************************

 

<apex:page controller="NewController" >
    
      <apex:form id="theForm">
    
        <apex:pageBlock title="My Accounts">
      
          
                <apex:pageblocktable value="{!myaccounts}" var="acct">
                    <apex:column headervalue="Account">
                         <apex:outputField value="{!acct.Name}" />
                         <apex:inputField value="{! acct.Name}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                   
                    <apex:column headervalue="Preferred Mode">
                         <apex:outputfield value="{!acct.Preferred_Mode_s__c}"/>
                         <apex:inputfield value="{!acct.Preferred_Mode_s__c}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                     
                    <apex:column headervalue="Type">
                         <apex:outputField value="{!acct.type}" />
                         <apex:inputField value="{! acct.type}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                   
                    <apex:column headervalue="DQ Reason">
                         <apex:outputField value="{!acct.DQ_Reason__c}" />
                         <apex:inputField value="{! acct.dq_reason__c}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                 
                </apex:pageblocktable>
                <apex:commandButton value="Save" action="{!save}" rerender="theForm"/>
            <apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
        </apex:pageblock>
  </apex:form>
</apex:page>

 

Plz help me , I have no idea about aggregate results.

 

display last two weeks opportunities sum(amount) group by stagename="closed won" and stagename ="closed lost"

 

 

week wise   closed wons  closed losts

 

1st week        2000/-              100/-             ( total opportunities in 1st week )

 

2nd week       2500/-               250/-            (total opportunities in 2st week)

 

 

please post controller

Hi All,

I have the following lightning component which input data from custom object using aura:iteration and input components. There are two buttons to add and remove a row. If the page loads and you click on remove row it works. But when you click on Add Row and then click on Remove Row, it doesnt work.

Can someone help?



Criteria.cmp
<aura:component controller="ValidationCreationController" implements="force:appHostable">
	<ltng:require styles="/resource/slds/assets/styles/salesforce-lightning-design-system.min.css"/>
    <aura:attribute name="valCriteriaList" type="Rule_Criteria__c[]"
                    access="public"/>
    <aura:attribute type="SelectOption[]" name="appliesToOptions" access="private" />
    <aura:attribute type="SelectOption[]" name="categoryOptions" access="private" />
    <aura:attribute type="SelectOption[]" name="criteriaOptions" access="private" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
	<div class="container">
    	<form class="slds-form--compound">
            <div class="form-element__group">
                <aura:iteration var="ruleCriteria" items="{!v.valCriteriaList}">
      				<div class="slds-form-element__row">
                    	<div class="slds-form-element slds-is-required slds-size--1-of-12">
                        	<ui:inputSelect class="slds-select"
                                            value="{!ruleCriteria.Applies_To__c}">
                                <aura:iteration items="{!v.appliesToOptions}" var="app">
                                     <ui:inputSelectOption text="{!app.value}" label="{!app.label}"/>
                                </aura:iteration>
                            </ui:inputSelect>
                    	</div>
                    	<div class="slds-form-element slds-is-required slds-size--1-of-12">
                      		<ui:inputNumber class="slds-input"  
                                    value="{!ruleCriteria.Rule_Hierarchy__c	}" 
                                    required="true" placeholder="Rule Hierarchy" />
                    	</div>
                    	<div class="slds-form-element slds-is-required slds-size--5-of-12">
                        	<ui:inputText class="slds-input" 
                                          value="{!ruleCriteria.Validation_Logic__c}"
                                          placeholder="Validation Logic"
                                          /> 
                    	</div>
                    	<div class="slds-form-element slds-is-required slds-size--1-of-12">
                        	<ui:inputSelect class="slds-select" 
                                            value="{!ruleCriteria.Criteria__c}">
                                <aura:iteration items="{!v.criteriaOptions}" var="crc">
                                     <ui:inputSelectOption text="{!crc.value}" label="{!crc.label}"/>
                                </aura:iteration>
                            </ui:inputSelect>
                    	</div>
                    	<div class="slds-form-element slds-is-required slds-size--1-of-12">
                        	<ui:inputSelect class="slds-select" 
                                            value="{!ruleCriteria.Validation_Category__c}">
                                <aura:iteration items="{!v.categoryOptions}" var="cat">
                                     <ui:inputSelectOption text="{!cat.value}" label="{!cat.label}"/>
                                </aura:iteration>
                            </ui:inputSelect>
                    	</div>
                    	<div class="slds-form-element slds-is-required slds-size--1-of-12">
                             <ui:inputText class="slds-input" 
                                           value="{!ruleCriteria.Message_Code__c}"
                                           placeholder="Message Code" /> 
                    	</div>
                        <div class="slds-form-element slds-is-required slds-size--1-of-12">
                             <ui:inputText class="slds-input" 
                                           value="{!ruleCriteria.Message_Past_Tense__c}"
                                           placeholder="Message Past Tense" /> 
                    	</div>
                        <div class="slds-form-element slds-is-required slds-size--1-of-12">
                             <ui:inputText class="slds-input" 
                                           value="{!ruleCriteria.Msg_Present_Tense__c}"
                                           placeholder="Message Present Tense" /> 
                    	</div>
                	</div>
                </aura:iteration>
                <div class="slds-form-element__row">
                    <div class="slds-form-element">
                        <ui:button aura:id="addRow" 
                                   buttonTitle="Click to add new row" 
                                   class="button" 
                                   label="Add Row" press="{!c.addRow}"/>
                        <ui:button aura:id="removeRow" 
                                   buttonTitle="Click to remove row" 
                                   class="button" 
                                   label="Remove Row" press="{!c.removeRow}"/>
                        
                    </div>
             	</div>                
            </div>
        </form>
    </div>
</aura:component>

Java script Controller
 
({
    doInit : function(component, event, helper) {
        //alert('test');
		helper.addRow(component,helper);
        helper.getAppliesTo(component,helper);  
        helper.getCategory(component,helper);
        helper.getCriteria(component,helper);
    },
    addRow : function(component, event, helper) {
      	helper.addRow(component,helper);  
    },
    removeRow : function(component, event, helper) {
        helper.removeRow(component,helper); 
    },
})

Helper
 
({
	addRow : function(component,helper) {
        var validationCri = {  'sobjectType' : 'Rule_Criteria__c',
                                'Applies_To__c' : 'Horse' ,
                                'Criteria__c' : 'Is Met' };
        var validationCriterList = component.get("v.valCriteriaList");
        validationCriterList.push(validationCri);
        component.set("v.valCriteriaList", validationCriterList);
    }, 
    removeRow : function(component,helper) {
        var validationCriterList = component.get("v.valCriteriaList");
 		validationCriterList.pop();
        console.log(validationCriterList);
		component.set("v.valCriteriaList", validationCriterList);
        console.log(validationCriterList);
        
    },
	getAppliesTo : function(component,helper) {
		var action = component.get("c.getAppliesTo");
        helper.populateDropDown(component,action,"v.appliesToOptions");
	},
    getCategory : function(component,helper) {
		var action = component.get("c.getCategory");
        helper.populateDropDown(component,action,"v.categoryOptions");
	},
    getCriteria : function(component,helper) {
		var action = component.get("c.getCriteria");
        helper.populateDropDown(component,action,"v.criteriaOptions");
	},
    populateDropDown : function(component,action,attr) {
    	var opts = [];
    	action.setCallback(this, function(a) {
            for(var i=0;i< a.getReturnValue().length;i++){ 
                opts.push({label: a.getReturnValue()[i].label, value: a.getReturnValue()[i].value});
            }
            component.set(attr, opts);
        });
        $A.enqueueAction(action);
	},
})

 

Hi All,

 

I am having really tough time dealing with Salesforce Test classes.

 

My first problem is when I write a test class, then the class I am testing does not show up in Overall Code Coverage.

 

Then when I click on test the class does show up in Class Code Coverage and show me the coverage % but when I click on it it opens without the colors telling me which line is covered and which is not.

 

 

Please let me know how to resolve this.

 

Thanks.

Hi All,

 

I am trying to enforce some security in some objects. What I am trying to do is this. I have two records A and B with master detail relationship with A being the master. Now I want users to see all information of A except for some secure fields. This I have achieved through field level security. Next in detail object I have a checkbox which denotes that this record is secure and should be shown to some users only. How can I implement this using Salesforce default functionality or is there any other solution as well? Also, I would like to hide events/tasks from users.

 

 

Thanks,

Puneet

Hi,

 

I am trying to obtain access token through REST client plugin of Chrome using the following request for development purposes. I am using the following request.

 

 

https://cs13.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=CONSUMER_KEY" -d "client_secret=CONSUMER_SECRET" -d "LOGINID" -d "password=PASSWORDWITHSECURITYKEY"

 

where I am filing CONSUMER_KEY,CONSUMER_SECRET, LOGINID and PASSWORDWITHSECURITYKEY.

 

But I am getting the following response.

 

  1. Status Code: 404 Not Found
  2. Content-Type: text/html;charset=UTF-8
  3. Date: Mon, 15 Jul 2013 10:24:21 GMT
  4. Transfer-Encoding: chunked

I do not know where I am going wrong. Can somebody please help.

Hi,

 

I have wrote an inbound email service. I am using Inbound Envelope Object from address field to populate some data. But I can see for some data this field is blank. Can somebody tell me how is this happening? Why  from address field of Inbound Envelope is blank?

 

Thanks

Hi,

 

Where can I find email of my Salesforce organization? I mean i need to test my InboundEmailHandler class. But what's the id where I should send email? How can I find that?

 

 

Thanks,


Puneet

Hi,

 

I am having an existing dahboard in which I have 3 filters. Now I am not able to filter on these 3 filters.

 

I am getting the following

 

The filter is invalid because not all of the components can be filtered on the choosen field. Remove the filter or change the data sources.

 

 

But now when i create brand new dashboard with same component and reports, it does not show above error.

 

 

Can somebody tell me why I am getting error in old one and not in the new one?

 

 

Thanks

Hi,

 

How can one check out if Salesforce release is in production?Whether all new limits are in effect?

Hi,

 

I am trying to retrieve history of field Salary at my custom object Employee. I am using the following query :-

 

List<Employee__c> lstEmp=[SELECT Id,Salary__c,
                          (SELECT OldValue,NewValue, FROM Histories)
                          FROM Employee__c                        
                         ];

Now I need to retrieve a particular field only which is salary, I do not want other fields tracking details and I need to get date at which the change is made. Please let me know how should i modify my query and if you have the link to the documentation of history object present in salesforce please post that.

 

 

Thanks in advance....

I am performing some validation on click of button

 

<apex:commandButton styleClass="cmdButton" style="background: green;" value="{!if(timesheet3.Status__c == 'To Be Approved','Verify Timesheet','Approve Timesheet')}" onclick="javascript&colon;displayHoursPerWeekError('{!hoursPerWeekError}')" rerender="msg" />

 

function displayHoursPerWeekError(display)
{
if(display=='true')
{

var agree=confirm("Hours per week is less, are you sure you want to submit timesheet?");
if (agree)
{
approval();
return true ;
}
else
return false ;
}
else
{
alert('this');
approval();
return true;
}
}

If validation is true then I am calling submitApprove function at the controller using action function. Now after completing the request I need to get a property defined at controller to determing whether to close the window or not. But the alert('{!Test}'); prints blank although for testing purpose I am just returning false from this property.

 

<apex:actionFunction action="{!submitApprove}" oncomplete="Javascript&colon;alert('{!Test}');if('{!closeWindow}' == 'true') {window.close();};"  name="approval"/>

Hi All,

 

I am having really tough time dealing with Salesforce Test classes.

 

My first problem is when I write a test class, then the class I am testing does not show up in Overall Code Coverage.

 

Then when I click on test the class does show up in Class Code Coverage and show me the coverage % but when I click on it it opens without the colors telling me which line is covered and which is not.

 

 

Please let me know how to resolve this.

 

Thanks.

Hi All,

 

I am trying to enforce some security in some objects. What I am trying to do is this. I have two records A and B with master detail relationship with A being the master. Now I want users to see all information of A except for some secure fields. This I have achieved through field level security. Next in detail object I have a checkbox which denotes that this record is secure and should be shown to some users only. How can I implement this using Salesforce default functionality or is there any other solution as well? Also, I would like to hide events/tasks from users.

 

 

Thanks,

Puneet

I want to create a custom app that whenever a CRM user accesses one of their contacts it will send a POST request to my external server. Is there a way to do this with just VisualForce or do I need to look into Apex programming.

 

thanks in advance.

 

How to query records from recycle bin?

All -

 

I am creating an email messaging service and I understand how to do it with text in the body, however this specific e-mail is being sent with XML format in the body. Does anyone know the best way to indicate the next line for this type of format? I understand the code for next line etc...but this one is new to me. Any assistance would help.

 

 

Hi,

 

In my project, i developed trigger on Task object. My requirement is:

 

1. Task has the field Description which is text-area long.

2. When we try to update the description with the new data, it should append to the existed value.

3. But, here on clicking edit button, the old value is appearing in the text area and the user adds the notes to that existed data.

4. Then, the existed data along with new data is appending with the existed value.

 

For example:

 

Task Object

 

1. Task description field old value: "Testing One"

2. Task description field new value: "Testing One Testing Two". (Because, here while clicking on edit, existed data is available. The user enters the new data along with old value).

 

Now, the updated task description field value is: "Testing One Testing One Testing Two". But, the user expect that it should be "Testing One Testing Two.".

 

I thought of using javascript here. When clicking on Edit button, it clears the old value of the description field. Then, the user enters the new data only. that will append to the existed one.

 

How could i use javascript while clicking on edit(Standard button) and how to implement the functionality for clearing the text area field?

 

Please suggest me in this how to fix this issue?

 

Thanks in advance.

 

Regards,

kumar

Very straight forward listview table of account records - see apex:pageblocktable below

 

Within this account listview table, we have a checkbox field at the account object as shown in our listview. The user can check this box in the account listview apex:inputField value="{!a.Worked__c}" .

 

I need to save these checked Account Records when the user clicks on the apex:commandbutton to move as shown in the action="{!first}" or "{!previous}" call button selected.

 

I need to save the selected apex:inputField value="{!a.Worked__c}" / using the "ONCOMPLETE" attribute in the apex:commandbutton

 

EXAMPLE:

apex:commandbutton action="{!first}" value="First Group" ONCOMPLETE="{!xxSaveSelectedRecordsxx}" apex:commandbutton

 

Example ListView Table of Account Records:

apex:pageBlockTable id="AccountList" value="{!Accounts}" var="a"

apex:column value="{!a.Id}"/

apex:column value="{!a.Name}"/

apex:column headerValue="Worked?"> apex:inputField value="{!a.Worked__c}" / /apex:column>

apex:column value="{!a.Phone}"/> /apex:pageBlockTable>

 

Example Nav Buttons:

apex:commandbutton action="{!first}" value="First Group" /apex:commandbutton

apex:commandbutton action="{!previous}" value=" Previous Group" rendered="{!hasPrevious}">/apex:commandbutton apex:commandbutton action="{!next}" value="Next Group >" rendered="{!hasNext}">/apex:commandbutton>

apex:commandbutton action="{!last}" value="Last Group">/apex:commandbutton>

 

ONCOMPLETE String - The JavaScript invoked when the result of an AJAX update request completes on the client.

 

Thanks for your help....

Hi All,

 

My goal is to be able to have my Class grab a list of Task Records (which I know how to  do), perform a very simple calculation on them (which I do not know how to do) and then have the result be dropped into a field on the related Lead Record (which I know how to do). Would someone please help me understand how to perform simple calculations with the results of the query in my class or put me in the direction of documentation that might help? Thanks.

 

In case this helps, I am trying to create a 'Response Rate' field on the Lead Object. I want to look at all the Completed Tasks related to each Lead Record, then, grab all of the Task Records where the Type equals 'Email Sent' and 'Email Reply'. I woud then like to divide the number of Tasks where the Type is 'Email Sent' by the number of Tasks where the Type is 'Email Reply' and put that percentage into a field on the Lead called 'Response Rate'. 

Hi,

 

I am trying to obtain access token through REST client plugin of Chrome using the following request for development purposes. I am using the following request.

 

 

https://cs13.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=CONSUMER_KEY" -d "client_secret=CONSUMER_SECRET" -d "LOGINID" -d "password=PASSWORDWITHSECURITYKEY"

 

where I am filing CONSUMER_KEY,CONSUMER_SECRET, LOGINID and PASSWORDWITHSECURITYKEY.

 

But I am getting the following response.

 

  1. Status Code: 404 Not Found
  2. Content-Type: text/html;charset=UTF-8
  3. Date: Mon, 15 Jul 2013 10:24:21 GMT
  4. Transfer-Encoding: chunked

I do not know where I am going wrong. Can somebody please help.

Hello,

I created two sets of custom fields on my Leads Tab. One for Mailing Address and the other for Service Address. I'm trying to create a link on the page layout that would allow users to automatically copy the Mailing Address to the Service Address if they are they save. I saw this on the Contacts Tab in the Developer Edition and I would love to do the same in my org. I looked around in the Developer Edition to see if I could locate the code but I couldn't find it. Does anyone know how to code this? If so, I would really appreciate your help.

 

Thanks,

Daemyian

Greetings,

 

I have a dependent picklist that I need some validation on.  When "Disqualified" or "Recycled" is selected from the controlling field, I want the dependent field to be required.  The dependent field is only editable when "Disqualified" or "Recycled" are selected.  I implemented some code in the "Save" function but it does not work.  I am very new to APEX so any help is greatly appreciated.  My code is as follows:

 

***************************************************CONTROLLER******************************************************

public class NewController {    

          public List<Account> myAccounts;        

              public Boolean isEditEnabled;        

 

public NewController(){        

      myAccounts = new List<Account>();                

                IsEditEnabled = false;    

}

 

public List<Account> getMyAccounts(){        

         myAccounts = [select Id,name,type, dq_reason__c,preferred_mode_s__c,micro_industry__c from Account WHERE (owner.id =: userinfo.getuserid())];                   

         return myAccounts;              

}           

public PageReference edit() {                

          isEditEnabled = true;                              

          return null;       

}    

public PageReference save() {                              

         for (account a: myaccounts){                

            if(a.type == 'Disqualified' || a.type == 'Recycled'){                    

                If(a.dq_reason__c == 'NULL'){                        

                  apexpages.addmessage(new apexpages.message(ApexPages.severity.ERROR,'Please enter a DQ reason'));                        

}                    

}                    

}                

          update myAccounts;                

          isEditEnabled = false;        

return null;       

}

public Boolean getIsEditEnabled(){                

        return isEditEnabled;        

}

}

 

 

*******************************************VISUALFORCE PAGE***********************************************

 

<apex:page controller="NewController" >
    
      <apex:form id="theForm">
    
        <apex:pageBlock title="My Accounts">
      
          
                <apex:pageblocktable value="{!myaccounts}" var="acct">
                    <apex:column headervalue="Account">
                         <apex:outputField value="{!acct.Name}" />
                         <apex:inputField value="{! acct.Name}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                   
                    <apex:column headervalue="Preferred Mode">
                         <apex:outputfield value="{!acct.Preferred_Mode_s__c}"/>
                         <apex:inputfield value="{!acct.Preferred_Mode_s__c}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                     
                    <apex:column headervalue="Type">
                         <apex:outputField value="{!acct.type}" />
                         <apex:inputField value="{! acct.type}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                   
                    <apex:column headervalue="DQ Reason">
                         <apex:outputField value="{!acct.DQ_Reason__c}" />
                         <apex:inputField value="{! acct.dq_reason__c}" rendered="{!IsEditEnabled}"/>
                    </apex:column>
                 
                </apex:pageblocktable>
                <apex:commandButton value="Save" action="{!save}" rerender="theForm"/>
            <apex:commandbutton value="Edit" action="{!edit}" rerender="theForm"/>
        </apex:pageblock>
  </apex:form>
</apex:page>