• ColinKenworthy1
  • NEWBIE
  • 70 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 43
    Replies

Hi,

 

Very new to salesforce APEX development.  

 

I have created a custom object called file note (file_note__c).  

 

The object contains a checkbox field called new opportunity (new_opportunity__c).  

 

When I save a new or updated file note record I want a trigger to run.

 

Trigger

 

If the 'new opportunity checkbox' is ticked (set to true) I need to create a new opportunity (as in take me to create a new opportunity page).

 

Best case scenario would be to have the new opportunity created and linked to the filenote (a simple lookup on file note called (opportunity__c).  And the opportunity to be in edit mode to fill in some of the data.

 

However if that's not possible just the ability to create a new activity will be fine. 

 

 

Apologies I have no idea how to begin, any advice would be much appreciated. 

The Case's related object EmailMessage gets Insert and Delete triggers but not any Update triggers. So I can't do anything useful when users read or reply to an email (and the Status changes from New to Read or Replied).

 

Any explanations from SF as to why they haven't given us access to an Update trigger on this object? Is it an oversight or bug?

 

Can anyone think of any sort of workaround (I can't)?

 

regards.

I have some custom datetime fields on Case and I get them with the time included but when I try to get ClosedDate I only receive the date part!

 

e.g.

var redDateStr = '{!Case.VI_Red_Time__c}'; alert( 'red ' + redDateStr); var isClosed = '{!Case.IsClosed}'; /* "0"=open, "1"=closed */ var closedDateStr = '{!Case.ClosedDate}'; alert('closed ' + closedDateStr); var openedDateStr = '{!Case.CreatedDate}'; alert('opened ' + openedDateStr);

So my custom datetime field displays a date and time, the two standard fields only display date. I've looked at the record in eclipse and the standard fields do have a time element to them so not sure why the above isn't working?

For ClosedDate and CreatedDate I should be seeing a time element in the alert boxes.

I dont see a UserInfo.getUserEmail() method to use in Apex.

 

In formula fields you can use $User.Email

 

Is the only way in Apex to run a Select statement ?

I created a visualforce email template (and it works OK) just the preview on the template page does not show.

 

"Error occurred trying to load the template for preview: collection exceeds maximum size: 1001. Please try editing your markup to correct the problem."

 

Anyone know what the error is referring to?

I did not find anything searching for it.

I'm creating a VF page for Solutions but the SolutionName and SolutionNote input fields display way too small.

 

In the regular screens they display quite large and there is room for plenty of text to be entered before anything starts scrolling.

 

 

 

Am I missing some parameter screen where you can specify the input field width ?  Is it something you can do in Apex ?

My csv has 2009-09-15 (or 15/09/2009 if I tick european date formats in Data Loader settings). Then I insert the csv but when I view the record it shows 14/09/2009. How can it change the date!!

 

Both my user and org are set up in the GMT (British Summer Time) time zone so I don't get it.

Also my PC is set to GMT with 'adjust for daylight saving' ticked.

 

 

British Summer Time ends on Oct 25 and if I put 26/10/2009 in the csv the date is not changed. It displays 26/10/2009 as it should do.

I would like to highlight or color either the cell or the entire row when a user clicks on a commandLink in a table. I'm currently using a VF pageBlockTable but want somehow for the user's selection to persist on screen while another part of the screen is redrawn. Also if the user clicks on a different row then the original cell/row should revert to the default color and the newly clicked cell/row should be changed.

 

 

Does anyone have any code snippets / suggestions ?

Is there an Apex equivalent of the API call describeSObject?

 

Since API 15.0 moving a string to the target string that is longer than the target string's length causes an error.

I'd like to discover the target string's length in advance to I can move a substring of the original string and avoid the error. i.e.

 

integer i = /** code here to discover length of targetString__c **/; myCustomObj__c.targetString__c = Left('Some really long string value for targetString__c', i );

 

I have a custom detail object that is the detail in two master-detail relationships. Both master objects are also custom. The owners of the 2 master records (that relate to a particular detail record) will never be the same, yet the detail record inherits its sharing rules from the master rec!

So right now I have users that can see their own master records but cannot see any detail records.

 

e.g. detail rec C(obj3) belongs to 2 master recs A(obj1) and B(obj2) - a user who can correctly see rec A cannot see the detail rec C.

 

Any ideas how I open up sharing rules so users that can see recs A and B would also see their rec C?

Nomal behaviour in vf tables is to display one object per row of a table, with your desired fields as columns.

I'm trying to create a page where only one field per object is shown but they are displayed horizontally.

 

<apex:dataTable id="teamtable" value="{!MyTeam}" var="person">
  <apex:column > <apex:image url="{!person.Photo_URL__c}" height="150" width="200" /> </apex:column>
  <apex:column > <apex:outputText value="{!person.Name__c}" /> </apex:column>
</apex:dataTable>

 

So this is displaying all the team members vertically with a lot of white space on the right. Ideally I'd like to have 4 or 5 team members photos on a line each with their name underneath. Is this possible in VF ?

 

Nomal behaviour in vf tables is to display one object per row of a table, with your desired fields as columns.

I'm trying to create a page where only one field per object is shown but they are displayed horizontally.

 

<apex:dataTable id="teamtable" value="{!MyTeam}" var="person">
  <apex:column > <apex:image url="{!person.Photo_URL__c}" height="150" width="200" /> </apex:column>
  <apex:column > <apex:outputText value="{!person.Name__c}" /> </apex:column>
</apex:dataTable>

 

So this is displaying all the team members vertically with a lot of white space on the right. Ideally I'd like to have 4 or 5 team members photos on a line each with their name underneath. Is this possible in VF ?

 

The Case's related object EmailMessage gets Insert and Delete triggers but not any Update triggers. So I can't do anything useful when users read or reply to an email (and the Status changes from New to Read or Replied).

 

Any explanations from SF as to why they haven't given us access to an Update trigger on this object? Is it an oversight or bug?

 

Can anyone think of any sort of workaround (I can't)?

 

regards.

hi,all

 

 

now I'm developing calculation application.

while I'm developing my application, I wonder how to write array.

 

I want to use two random numbers by using array, so I write a code like this below.

 

 

 

     public Integer getRandomNumber1() {
    
          List<Integer> random = new Integer[2];
                   
          random.set(0, Math.round(Math.random()*100));

          random.set(1, Math.round(Math.random()*100));

 

          return random.get(0);

          return random.get(1);

 

     }
 

 

I need to return two random numbers in  getRandomNumber1 class.

 

Then I display two random numbers in a visualforce page.

 

 

I appreciate any advice.

 

thanks

  • November 08, 2009
  • Like
  • 0

I dont see a UserInfo.getUserEmail() method to use in Apex.

 

In formula fields you can use $User.Email

 

Is the only way in Apex to run a Select statement ?

Hi,

 

I am still new to coding triggers and coding in general but I have a problem that I am struggling to get around.

 

The trigger I currently have fires after update and transfers a completed field to another objects field. 

 

The problem is this happens after every Account update, I need this only to happen after the one field (IF_SAP__c) has changed, and if that field hasn't changed then do not do the update.

 

 This my current code, I understand I can use the Trigger.old, but I dont know how to compare the Trigger.old to the Trigger.new. Can some one please point me in the right direction.

 

Many Thanks


Matt

 

 

trigger UpdateToAccSetupForm on Account (after update) { Map<String, String> SetupFormMap = new Map<String, String>(); for (Account acc : System.Trigger.new){ if (acc.IF_SAP__c != null){ SetupFormMap.put(acc.ID, acc.IF_SAP__c); } else{ } } List<AccountSetupForm__c> recordsforupdates = new list<AccountSetupForm__c>(); for (AccountSetupForm__c aacc :[Select Id, AccountName__c, SAP_Number__c from AccountSetupForm__c where AccountName__c IN : SetupFormMap.keySet()] ){ if (SetupFormMap.containsKey(aacc.AccountName__c)) { aacc.SAP_Number__c = SetupFormMap.get(aacc.AccountName__c); recordsforupdates.add(aacc); } } update recordsforupdates; }

 

 

 

Hi,

 

Very new to salesforce APEX development.  

 

I have created a custom object called file note (file_note__c).  

 

The object contains a checkbox field called new opportunity (new_opportunity__c).  

 

When I save a new or updated file note record I want a trigger to run.

 

Trigger

 

If the 'new opportunity checkbox' is ticked (set to true) I need to create a new opportunity (as in take me to create a new opportunity page).

 

Best case scenario would be to have the new opportunity created and linked to the filenote (a simple lookup on file note called (opportunity__c).  And the opportunity to be in edit mode to fill in some of the data.

 

However if that's not possible just the ability to create a new activity will be fine. 

 

 

Apologies I have no idea how to begin, any advice would be much appreciated. 

I created a visualforce email template (and it works OK) just the preview on the template page does not show.

 

"Error occurred trying to load the template for preview: collection exceeds maximum size: 1001. Please try editing your markup to correct the problem."

 

Anyone know what the error is referring to?

I did not find anything searching for it.

Hello,

 

I'm attaching a custom button to the account page that opens a new window which is Visual Force.  I want the user to enter in information, click a submit button, and then update the account and refresh the account page.  Is there anyway I can do this?

 

I've tried some Javascript but I get a  permission denied error.

I'm creating a VF page for Solutions but the SolutionName and SolutionNote input fields display way too small.

 

In the regular screens they display quite large and there is room for plenty of text to be entered before anything starts scrolling.

 

 

 

Am I missing some parameter screen where you can specify the input field width ?  Is it something you can do in Apex ?

Sometimes when I close out a screen I accidentually close down the Salesforce.com program. Is there a way to program salesforce when it closes to ask " Do you really want to do this?"

I would like to highlight or color either the cell or the entire row when a user clicks on a commandLink in a table. I'm currently using a VF pageBlockTable but want somehow for the user's selection to persist on screen while another part of the screen is redrawn. Also if the user clicks on a different row then the original cell/row should revert to the default color and the newly clicked cell/row should be changed.

 

 

Does anyone have any code snippets / suggestions ?

Hello:

 

I am trying to update my new Entitlement fields with my old Entitlement fields data (date and time).

I was able to format the cells using the following yyyy-mm-ddThh:mm:ss.sssZ which changes the filed to the following format 2007-01-06T00:00:00.000Z and update the fields using Data Loader.

We use multiple time zones - the day on the field is correct, but it changed the time to GMT.

Does anyone know how to format the field so it shows the correct time?

 

Thanks,

Eileen

 

Visualforce is adding some Javascript to my email templates that gets displayed in the Activity History and also in at least one email client out on the 'net. The content of the script doesn't even look like it is essential to the template.

 

First, the code as it appears in my .email file:

 

<apex:repeat var="cx" value="{!relatedTo.OpportunityLineItems}">
<tr>
<td>{!cx.PricebookEntry.product2.description}</td>
<td><div align="right"><apex:outputField value="{!cx.UnitPrice}"/></div></td>
<td><div align="right"><apex:outputField value="{!cx.Quantity}"/></div></td>
<td>&nbsp;</td>
</tr>
</apex:repeat>

 

 Pretty straightforward usage, just building a dynamic table of Opportunity Products.

The HTML and Javascript that appears for that exact same portion, when repeated twice for two records, is:

 

<tr>
<td>mCLASS&reg;:DIBELS&reg; Software Annual Student Subscription</td>
<td><div align="right"><script type="text/javascript"> if(!window.sfdcPage){window.sfdcPage = new ApexPage();}
UserContext.initialize({'locale':'en_US','timeFormat':'h:mm a','today':'5\/19\/2009 6:09 PM','userPreferences':[{'value':true,'index':112,'name':'HideInlineEditSplash'}
,{'value':true,'index':114,'name':'OverrideTaskSendNotification'}
,{'value':false,'index':115,'name':'DefaultTaskSendNotification'}
,{'value':false,'index':119,'name':'HideUserLayoutStdFieldInfo'}
,{'value':false,'index':116,'name':'HideRPPWarning'}
,{'value':false,'index':87,'name':'HideInlineSchedulingSplash'}
,{'value':false,'index':88,'name':'HideCRUCNotification'}
,{'value':true,'index':89,'name':'HideNewPLESplash'}
,{'value':false,'index':90,'name':'HideNewPLEWarnIE6'}
,{'value':false,'index':122,'name':'HideOverrideSharingMessage'}
],'startOfWeek':'1','isAccessibleMode':false,'ampm':['AM','PM'],'userId':'00530000000pvUP','dateTimeFormat':'M\/d\/yyyy h:mm a','dateFormat':'M\/d\/yyyy','language':'en_US','siteUrlPrefix':''}
);
</script><span id="j_id0:emailTemplate:j_id3:j_id4:j_id16:0:j_id20">$6.00</span></div></td>
<td><div align="right"><span id="j_id0:emailTemplate:j_id3:j_id4:j_id16:0:j_id22">100.00</span></div></td>
<td>&#160;</td>
</tr>

<tr>
<td>mCLASS&reg; Platform Annual Student Subscription</td>
<td><div align="right"><span id="j_id0:emailTemplate:j_id3:j_id4:j_id16:1:j_id20">$8.00</span></div></td>
<td><div align="right"><span id="j_id0:emailTemplate:j_id3:j_id4:j_id16:1:j_id22">100.00</span></div></td>
<td>&#160;</td>
</tr>

 

I know that Visualforce processes the code and converts it to HTML, but I just cannot figure out what purpose this <script> has:

<script type="text/javascript"> if(!window.sfdcPage){window.sfdcPage = new ApexPage();}
UserContext.initialize({'locale':'en_US','timeFormat':'h:mm a','today':'5\/19\/2009 6:09 PM','userPreferences':[{'value':true,'index':112,'name':'HideInlineEditSplash'}
,{'value':true,'index':114,'name':'OverrideTaskSendNotification'}
,{'value':false,'index':115,'name':'DefaultTaskSendNotification'}
,{'value':false,'index':119,'name':'HideUserLayoutStdFieldInfo'}
,{'value':false,'index':116,'name':'HideRPPWarning'}
,{'value':false,'index':87,'name':'HideInlineSchedulingSplash'}
,{'value':false,'index':88,'name':'HideCRUCNotification'}
,{'value':true,'index':89,'name':'HideNewPLESplash'}
,{'value':false,'index':90,'name':'HideNewPLEWarnIE6'}
,{'value':false,'index':122,'name':'HideOverrideSharingMessage'}
],'startOfWeek':'1','isAccessibleMode':false,'ampm':['AM','PM'],'userId':'00530000000pvUP','dateTimeFormat':'M\/d\/yyyy h:mm a','dateFormat':'M\/d\/yyyy','language':'en_US','siteUrlPrefix':''}
);
</script>

 


Anyone else seen this in their Visualforce templates? Is it normal and I just have to accept that crappier email clients can't deal with JS in the <body>? I find it suspicious that it shows up in Task rendition of the Activity History.

 

Thanks for shedding any light you can,

Luke C

 

 

Message Edited by Always Thinkin on 05-22-2009 03:04 PM
Message Edited by Always Thinkin on 09-23-2009 11:05 AM

Hi,

 

     I have a trigger on opportunity update which will update the opportunity line items  accordingly.

 

     Through the debug log I found the trigger is triggered twice, even though I specify it will only be triggered if there is a stage change from sA to sB. 

 

     From the discussion board, I found the reason is due to certain workflow rule did field update right after the trigger. But the funny thing is after the first firing, the previous stage of the opportunity is still considered as sA instead of sB, while the opportunity line items data did accumulated after the firing.

 

     In the end, the number of line items doubled.  Although I have ways to prevent the line items from the second round of accumulation, I am just curious how to deal with the second fire of trigger?

 

 

     Btw, I found the governer limit of SOQL in sandbox increased from 20 to 100! Good news!

 

 

Thanks,

Dawn

Message Edited by dawnzdy on 04-15-2009 12:23 PM

I have used the same code as provided for exporting in my application.In Windows the excel gets exported in a proper manner but when I try to export in MAC OS I get the code written inside the script tag from Salesforce's side.Here is the gibberish code that I get

 


if(!window.sfdcPage){window.sfdcPage = new ApexPage();}
UserContext.initialize({'isAccessibleMode':false,'ampm':['AM','PM'],'locale':'en_US','dateTimeFormat':'M/d/yyyy h:mm a','today':'1/28/2009 2:37 AM','dateFormat':'M/d/yyyy','language':'en_US','siteUrlPrefix':'','userPreferences':[{'value':false,'index':119,'name':'HideUserLayoutStdFieldInfo'}
,{'value':false,'index':87,'name':'HideInlineSchedulingSplash'}
,{'value':false,'index':116,'name':'HideRPPWarning'}
,{'value':false,'index':115,'name':'DefaultTaskSendNotification'}
,{'value':false,'index':114,'name':'OverrideTaskSendNotification'}
,{'value':false,'index':112,'name':'HideInlineEditSplash'}
],'startOfWeek':'1'}
);

 

Is this a SalesForce bug or an error from our side.If it is an error do I need to log a bug??