• Karthikeyan Jayabal
  • NEWBIE
  • 179 Points
  • Member since 2013

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 38
    Replies

I have the requirement  create a trigger on Attachment object, when i add new attachment ,check the attchment alredy aded or not?

 

i write like this ,please suggest me, is it correct or not?

 

 

trigger dntAddDuplicateAttchmnt on Attachment (before insert) {
if(trigger.isBefore){
for(Attachment atch:Trigger.new){
String parentID=atch.ParentId;
String atchName=atch.Name;
List<Attachment> listatch=[SELECT Name,ParentId FROM Attachment];
if(parentID==trigger.oldmap.get(parentID).ParentId && atchName==trigger.oldmap.get(parentID).Name){
atch.addError(' This file already having with same name in your attachmntes');
}
else if{
for(Attachment at:listatch){
if(at.Name==atchName && at.ParentId==parentID){
atch.addError('This file already having with same name in your attachmntes');
}
}
}

}
}

}

hi 

I am a newbie .

Please help me how to create a VF page based on following

1 . There is piclklist containg 2 values credit/debit

2. And based on the value selected a textbox will be created ether debit or credit .

 

Thanks

Hi all,

 

I have to calculate the total time spent on a case. We have 5 status called new open pending working closed. So when ever the status is in working then the time is not supposed to be calculated. For this I have written a trigger which subtratcs the waiting time from total time. But looks like I had a problm. 

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger caselifetimecalculator caused an unexpected exception, contact your administrator: caselifetimecalculator: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.caselifetimecalculator: line 6, column 1

 

 

Her is my code

 

trigger caselifetimecalculator on Case (before update) {
 
  for(Case c:Trigger.New){ 
   if(Trigger.oldMap.get(c.id).status != c.status)
       if(Trigger.oldMap.get(c.id).status !='Waiting' )
           c.total_activity_time__c +=  (datetime.now().getTime()- (c.CaseStatusLastModified__c == null ? c.CreatedDate.getTime() :c.CaseStatusLastModified__c.getTime()))/(1000*60);
       c.CaseStatusLastModified__c= datetime.now();
  }
 
}
 
 
 
Please create two fields on Case and expose"Total Activity Time" on layout.
 
 
 
     label                           type                     api                                           Help text
1.. "Total Activity time"    Number (10,5)  total_activity_time                        In seconds.       
2. "casestatuslastmodified" Date/time     CaseStatusLastModified

 

 

Hello everyone,

I am trying here to use the result of a Picklist value to get a list of related object. Although the Selected value is visible cleary in ViewState, it is not actuated in the related object Select statment. Why?

Thanks in advance for your help

Jerome

Controller

public with sharing class CNModConMoyCont {
public String MarqueSelected { public get; public set; }
public list<Organism__c> marqueList=[select Id, Name from Organism__c];
public list<Organism__c> getMarqueList(){return marqueList;}
public void setMarqueList(list<Organism__c> data) { marqueList=data; }
public List<SelectOption> marqueSelOpt;
public List<SelectOption> getMarqueSelOpt() {
List<SelectOption> options = new List<SelectOption>();
for (Organism__c Org : marqueList) {
options.add(new SelectOption( Org.Id, Org.Name));
}
return options;
}
public void setMarqueSelOpt(List<SelectOption> data) {marqueSelOpt=data;}
public list<Model__c> modelList { public get; public set; }
public CNModConMoyCont() {
modelList = [select Id, Name, Lien_Marque__c from Model__c where Lien_Marque__c =: MarqueSelected]; //always null
}
}

Page

<apex:page controller="CNModConMoyCont" showHeader="false" sidebar="false" id="CNModConMoy" >
<apex:form >
<apex:pageBlock >
<apex:selectList value="{!MarqueSelected}" multiselect="false" >
<apex:selectOptions value="{!marqueSelOpt}" />
</apex:selectList>
<apex:commandLink value="pick" rerender="datalist, modellist" />
<apex:outputPanel id="datalist" ><br/>
{!MarqueSelected}
</apex:outputPanel>
<apex:dataTable value="{!ModelList}" var="mod" id="modellist">
<apex:column >
<apex:outputText value="{!mod.Name}" />
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Hi All,

when I save the below formula, it shows this error:

 

Error: Compiled formula is too big to execute (19,959 characters). Maximum size is 5,000 character

 

if the sum of Value_1__c to Value_13__c <= 10, then  display level 1

if the sum of Value_1__c to Value_13__c >10 and Value_1__c to Value_13__c <= 18, then  display level 2

if the sum of Value_1__c to Value_13__c >18 then level 3

 

 

formula value:

if((Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c) <= 10

&&
(Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c ) <> 0 , "Level 1",
if( AND((Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c + Value_10__c + Value_11__c + Value_12__c + Value_13__c) > 10
&&
(Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c) <= 18), "Level 2",
if((Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c) > 18,"Level 3",
"Level Not Calculated Yet" )))

 

 

All field Value_1__c to Value_13__c also formula field which get s the value from the picklist selected.

 

we tried this also:

 

total_risk_cal__c = Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c


if((total_risk_cal__c) <= 10
&&
(total_risk_cal__c ) <> 0 , "Level 1",
if( AND((total_risk_cal__c) > 10
&&
(total_risk_cal__c) <= 18), "Level 2",
if((total_risk_cal__c) > 18,"Level 3",
"Level Not Calculated Yet" )))

 

but getting same error. We are trying an alternate method of creating a whole page using VF. We didn't get any ideal for how to give fomula field dynmaically in Visual force we are using professional edition. Kindly any one tell how to dao this and please send me any sample code for this also some links. Thanks in advance, waiting for you reply.

 

Regards,

Lavanya.

 

 

Hi All,

when I save the below formula, it shows this error:

 

Error: Compiled formula is too big to execute (19,959 characters). Maximum size is 5,000 character

 

if the sum of Value_1__c to Value_13__c <= 10, then  display level 1

if the sum of Value_1__c to Value_13__c >10 and Value_1__c to Value_13__c <= 18, then  display level 2

if the sum of Value_1__c to Value_13__c >18 then level 3

 

 

formula value:

if((Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c) <= 10

&&
(Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c ) <> 0 , "Level 1",
if( AND((Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c + Value_10__c + Value_11__c + Value_12__c + Value_13__c) > 10
&&
(Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c) <= 18), "Level 2",
if((Value_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c) > 18,"Level 3",
"Level Not Calculated Yet" )))

 

 

All field Value_1__c to Value_13__c also formula field which get s the value from the picklist selected.

 

we tried this also:

 

total_risk_cal__cValue_1__c + Value_2__c +Value_3__c + Value_4__c + Value_5__c + Value_6__c + Value_7__c + Value_8__c + Value_9__c+ Value_10__c + Value_11__c + Value_12__c + Value_13__c


if((total_risk_cal__c) <= 10
&&
(total_risk_cal__c ) <> 0 , "Level 1",
if( AND((total_risk_cal__c) > 10
&&
(total_risk_cal__c) <= 18), "Level 2",
if((total_risk_cal__c) > 18,"Level 3",
"Level Not Calculated Yet" )))

 

but getting same error.

 

 

Kindly tell how resolve this

 

 

Hello all,

We developed a VF page to override a custom object's New & Edit buttons. It uses a managed component (address validation component of Informatica package) & code structure is as shown below:
<apex:page standardcontroller="SVMXC__Site__c" extensions="Location_New_Edit_Controller">
	<apex:form>
		<apex:pageBlock>
			<apex:pageBlockSection>
				<apex:pageBlockSectionItem>
					<apex:outputPanel>
						<div>
							<DSE:DS_DataQuality.... parameters/>
						</div>
					</apex:outputPanel>
				</apex:pageBlockSectionItem>
			</apex:pageBlockSection>
		</apex:pageBlock>
	</apex:form>
</apex:page>

This page works fine in Google Chrome browser. The issue is it doesn't work consistently in IE 11 browser. But, it works in IE 11, only if we do the following:
1. First, load dse.visual.force.com/apex/pageName, then the usual c.visual.force.com/apex/pageName. DSE is the namespace of that Informatica installed package
2. Embed the same VF page in the object's standard page layout & access that record, then load the VF page

The above behaviours suggest that if a VF page uses a managed component, then some additional logic needs to be added to load the related JS libraries. 
Need your suggestions to fix this issue. Thank you! 
 
Hello all,

We developed a VF page to override a custom object's New & Edit buttons. It uses a managed component (address validation component of Informatica package) & code structure is as shown below:
<apex:page standardcontroller="SVMXC__Site__c" extensions="Location_New_Edit_Controller">
	<apex:form>
		<apex:pageBlock>
			<apex:pageBlockSection>
				<apex:pageBlockSectionItem>
					<apex:outputPanel>
						<div>
							<DSE:DS_DataQuality.... parameters/>
						</div>
					</apex:outputPanel>
				</apex:pageBlockSectionItem>
			</apex:pageBlockSection>
		</apex:pageBlock>
	</apex:form>
</apex:page>

This page works fine in Google Chrome browser. The issue is it doesn't work consistently in IE 11 browser. But, it works in IE 11, only if we do the following:
1. First, load dse.visual.force.com/apex/pageName, then the usual c.visual.force.com/apex/pageName. DSE is the namespace of that Informatica installed package
2. Embed the same VF page in the object's standard page layout & access that record, then load the VF page

The above behaviours suggest that if a VF page uses a managed component, then some additional logic needs to be added to load the related JS libraries. 
Need your suggestions to fix this issue. Thank you! 
 

Hi All,

         How can i  cretae a REST API in salesforce. i created a remote access in my dev org.

How can i create REST API Classs and Visualforce Page. in dev org.

 

please any one help me .

 

Thanks in Advance.

Hi,

 

 I hvave designed a VF page same as Edit opportunity page. And i have a button called "CBTN" , How to enable command button when select opportunity stage "Closed-Won" ohter wise it will disable mode.

 

My Page override with opportunity detail page edit button already record saved with stage name "Closed-Won" buttonautomatic enable when page load? 

I am using java script for button enable.but stage has action support for automatic probality how to include artomatic probablity also in java script.

 

Below is my script

<apex:includeScript value="{!URLFOR($Resource.Jqueryui18, 'js/jquery-1.7.1.min.js')}" />
<apex:includeScript value="{!URLFOR($Resource.Jqueryui18, 'js/jquery-ui-1.8.18.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.Jqueryui18,'css/smoothness/jquery-ui-1.8.18.custom.css')}"/>
<script type="text/javascript">
var $ = jQuery.noConflict();
$(document).ready(function()
{
//alert('gdhgh');
$("input[id$=':cbtn']").attr("disabled", "disabled");
});
function checkEnableSubmit(value)
{
//alert('wwwwwwww');
if (value=='6. Started Trading - Closed Won')
{
//alert('ddddddd');
$("input[id$=':cbtn']").removeAttr("disabled");
$("input[id$=':cbtn']").css("color","Black");
$("input[id$=':cbtn']").css("Cursor","pointer");
}
else
{
$("input[id$=':cbtn']").attr("disabled", "disabled");
$("input[id$=':cbtn']").css("color","gray");
}
}
</script>

 

 

Can any one help me? how to write java script for button enable and automatic  probability when stage select.

 

 

Thank you

 

 

 

 

<apex:actionregion >
<apex:inputField value="{!opp.stagename}"  onchage=" checkEnableSubmit()"> 
<apex:actionSupport onchage=" " /> </apex:inputfield>
</apex:actionregion>

 

 

 <apex:inputField value="{!opp.Probability}" id="probability"></apex:inputfield>

 

 

Hi,

 

I have written a batch class. In SingleEmailMessage, I have defined the To address and list of CC address.

CC address is equal to the number of contacts present in Account.

 

In schedule class, Batch Size of 1 is defined.

But I am getting the Error: Too many Emal invocation 11.

 

Please help me get the solution of this problem

 

Thanks,

  • June 16, 2013
  • Like
  • 0

Hi,


Please help me figure this one out. 

 

Do files posted on chatter count against the same limits as files in 'attachment'?

 

For some reason I recall reading that files attached on chatter counted towards a different limit?

 

Thanks,

Ben

  • June 15, 2013
  • Like
  • 0

I have the requirement  create a trigger on Attachment object, when i add new attachment ,check the attchment alredy aded or not?

 

i write like this ,please suggest me, is it correct or not?

 

 

trigger dntAddDuplicateAttchmnt on Attachment (before insert) {
if(trigger.isBefore){
for(Attachment atch:Trigger.new){
String parentID=atch.ParentId;
String atchName=atch.Name;
List<Attachment> listatch=[SELECT Name,ParentId FROM Attachment];
if(parentID==trigger.oldmap.get(parentID).ParentId && atchName==trigger.oldmap.get(parentID).Name){
atch.addError(' This file already having with same name in your attachmntes');
}
else if{
for(Attachment at:listatch){
if(at.Name==atchName && at.ParentId==parentID){
atch.addError('This file already having with same name in your attachmntes');
}
}
}

}
}

}

I am trying to create some shortcuts on the home page and one of the shortcuts should default to Current day to show "My Day"..as in this is what my calendar and tasks for today looks like..I am not sure how to construct the url. Appreciate the help!

 

Here is my code so far..this defaults to Jan 29th 2013..how do I get it to just show the current day? Thanks!!

 

 <td>
            <a href="/00U/c?cType=1&md0=2013&md3=29" target="_top"> <img src="{!$Resource.MyDay}" height="100" width="100" />   </a>
        </td>

 

We have our system setup so that when a case has been created by email-to-case, an email is sent to our customer informing  them we have received the case.  This email includes the reference number, so when the customer sends any followup emails, the email will correctly show up on the existing case and not create another case.  This works great.

 

However, how do I notify the case owner that the customer has sent a reply to an existing case when the email is received?

 

Thanks

  • June 07, 2013
  • Like
  • 0

Greetings!

 

I'll really appreciate your help if you can help me on how i can build a custom multi select picklist and for values, the name (records) from my custom object for example:

 

Object A

Name: test1

Name: test2

to N

 

The Multi Select Picklist values= test1, test2, to N

 

And add it for use it in my my opportunity page

 

Thank you !

Hello

I hope that someone can help me with my code

first, I have a vf page. In this page, there are sections that supposed to be hidden/shown according to the value of a multi-picklist. The standardController "Client Session Record" is a custome object

 

<apex:page standardController="Client_Session_Record__c">

  <apex:sectionHeader title="New client Session Record"
                      subtitle="{!Client_Session_Record__c.name}"/>
  <apex:form >
    
    <apex:pageBlock title="Client Session Record Edit" id="thePageBlock" mode="edit">
      <apex:pageMessages />
 
          <!--the buttons block  -->
          <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
          </apex:pageBlockButtons>
          <!--end of buttons block -->  

      <apex:actionRegion >
        <!--Section 1 -->   
        <apex:pageBlockSection title="Information" columns="2">
            

                  <apex:inputField value="{!Client_Session_Record__c.name}"/>
                  
                  <apex:pageBlockSection >
                      <apex:pageBlockSectionItem >

                      </apex:pageBlockSectionItem>

                      <!-- empty selectItem-->
                      <apex:pageBlockSectionItem />
                  </apex:pageBlockSection>
                  
                  
                  <apex:inputField value="{!Client_Session_Record__c.Date_of_visit__c}"/>
                  <apex:inputField value="{!Client_Session_Record__c.Advisor__c}"/>              
                  <apex:inputField value="{!Client_Session_Record__c.Client__c}"/>
                  <apex:inputField value="{!Client_Session_Record__c.X2nd_Advisor__c}"/>
                 
                  <!-- the condition -->
                  <apex:pageBlockSectionItem >              
                      <apex:outputLabel value="Session Type"/> 
                      <apex:outputPanel > 
                          <apex:inputField value="{!Client_Session_Record__c.Session_Type__c}">
                               <apex:actionSupport event="onchange"
                                            reRender="Section2, Section4"
                                            immediate="true"
                                            
                                            status="status"/>
                          </apex:inputField>
                          <apex:actionStatus startText="Updating the value..."
                                         id="status"/>
                      </apex:outputPanel> 
                  </apex:pageBlockSectionItem>
                  <!-- end of condition -->
                  <apex:inputField value="{!Client_Session_Record__c.Next_Review_Date__c}"/>
                  <apex:inputField value="{!Client_Session_Record__c.Location__c}"/>
                  
                          
        </apex:pageBlockSection>
        <!--Section 1 -->     
        
      </apex:actionRegion>
      

    <!--Section 2 -->  
          
      <apex:pageBlockSection title="Initial" id="Section2"
            columns="2" collapsible="true"  
            Rendered="{!if(Client_Session_Record__c.Session_Type__c=='Initial Assessment',true,false) }"  > 
                     
                     <apex:inputField value="{!Client_Session_Record__c.Recommended_AT__c}"
                         required="true" />  
                         
      </apex:pageBlockSection> 
       
    <!--Section 2 -->       
       
    </apex:pageBlock>
  </apex:form>
</apex:page>

 My problem is that , it didn't work!

 

How to Call Multi-select picklist in to Visual Force Page ? and check the selected Values 

I've got a complicated controller/pages package which I've been testing using runas(), in order to make sure that the guest profile has access to all the fields and objects it needs to.  My code:

 

//TRY TESTING THIS FOR THE WATERGRASS WEB PROFILE
Profile p = [SELECT Id FROM Profile WHERE Name='WaterGrass Web Profile']; 
      user u = new User(Alias = 'WGWeb', Email='WGWebUser@testorg.com', 
      EmailEncodingKey='UTF-8', LastName='WGWebUser', LanguageLocaleKey='en_US', 
      LocaleSidKey='en_US', ProfileId = p.Id, 
      TimeZoneSidKey='America/Los_Angeles', UserName='WGWebUser@testorg.com');
      insert u;

      System.runAs(u) {


CODE TO BE TESTED

}

 But in my most recent deployments, I run into this error: Insufficient Access ...: Cannot insert a user of type guest.

 

My questions:

  • Is this a new error type?
  • Is there some easy fix?
  • Does it matter whether I test using runas()?  I'm curious whether you other developers use this.

Thanks for your input,

Baird



This is my visual force page :

 

<apex:page standardController="Transaction__c" extensions="myControllerExtension">

<apex:form >
<h1>New Transaction</h1>
<apex:pageBlock >

<apex:pageBlockButtons location="top">
<apex:outputLabel value="Select Transaction Type:"/>
<apex:selectList multiselect="false" size="1" value="{!selectedValue}">
<apex:selectOptions value="{!options}"/>
<apex:actionSupport event="onchange" reRender="pbSection" status="pStatus"/>
</apex:selectList>
<apex:actionStatus id="pStatus" startText="Rendering..."/>
</apex:pageBlockButtons><br/><br/>

<apex:pageBlockSection id="pbSection" >
<apex:pageBlockSectionItem rendered="{!selectedValue='Credit'}">
<apex:outputLabel value="Credit:"/>
<apex:inputField value="{! Transaction__c.Credit__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!selectedValue='Debit'}">
<apex:outputLabel value="Debit:"/>
<apex:inputField value="{! Transaction__c.debit__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<br/><br/>

<apex:pageBlockSection >
<apex:inputField value="{! Transaction__c.To_Account_Number__c}"/><br/>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:inputField value="{! Transaction__c.Transaction_Amount__c}"/><br/>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:inputField value="{! Transaction__c.Transaction_Date__c}"/><br/>
</apex:pageBlockSection>

<apex:pageBlockSection >
<apex:commandButton action="{! save}" value="Save!"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

 

 

And this the apex class :

 

public with sharing class myControllerExtension {

    private final Transaction__c trans;
    
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.trans= (Transaction__c)stdController.getRecord();
    }

    public String selectedValue { get; set; }

    public List<SelectOption> getOptions() {
        List<SelectOption> options = new List<SelectOption>();
       
        options.add(new SelectOption('Credit','Credit'));
        options.add(new SelectOption('Debit','Debit'));
        return options;
    }
    
    public myControllerExtension () {
        selectedValue = 'Credit';
    }


   
}

 

 

My problem is that when i am running this page , I cannot see "Credit" & "Debit" input field.

 

In my apex class i had defined constructor , initializing its value to "Credit" but input field is not seen not even after changing it to debit.

 

Please help.

Trying to wrap my head around SOQL syntax and Joins.

I have been a SQL Server DBA/Developer for over 10 years and this Apex/SOQL stuff is confusion :-)

 

I need to Select all Account records where the associated Lead's Owner is like 'Queue')

 

First I tried this

SELECT Id FROM Account WHERE Id IN (SELECT Related_Owner__r.Id From Lead WHERE Owner.Name like '%Queue%')

 

But recieve the error "cannot have more than one level of relationships"

 

So I tried this

SELECT ID,(SELECT Owner.Name FROM Leads__r WHERE Owner.Name like '%Queue%') FROM Account 

 

This Runs but since it is a left join it returns all Accounts and any leads that match

 

I would like to do something like this

SELECT ID,(SELECT Owner.Name FROM Leads__r WHERE Owner.Name like '%Queue%') FROM Account  Where Leads__r.Id != null

 

But that does not work

 

How can I refrence a field form the right part of my join in the where clause

 

hi 

I am a newbie .

Please help me how to create a VF page based on following

1 . There is piclklist containg 2 values credit/debit

2. And based on the value selected a textbox will be created ether debit or credit .

 

Thanks