• JSam.ax761
  • NEWBIE
  • 0 Points
  • Member since 2010

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

I created a custom object and want to create a trigger that takes the value from one field to another field on the same object but the field to be populated by the trigger is a required field.  I'm against this because it's going to be the same value but that's what the boss wants.

 

I found a piece of simple code that populates a field when a new record is created and saved.  I have tweaked the code and it does populate the field, but since the field is required I have to type in any value first then when I save the record it populates with the correct value from the other field, hence my question can a trigger work on a required field where I don't have to type in a dummy value first.

 

I'm not a developer and my knowledge of Apex is basically finding sample code and trying it out to see what it does and then trying to tweak it, same with vocabularies.

 

Required field is "Profile Name" to be populated with same value as field titled "Solution"

 

Any help would be greatly appreciated

 

thanks

Hi everyone,
I actually built a "simplified search" option for our sidebar, and our teams love it!  It is a combination of a visualforce page and javascript. Follow the 4 steps below to do the same.  Hope this helps!

1) Create a Visualforce page called "advancedsearch"
2) Use the following code as your page (Hint: for the "&sen=" portions in bold, these identify the objects you want to search.  For example, &sen=001 is an Account (click on the Accounts tab, and you will see those three numbers in the hyperlink).  My code below searches: Accounts, Opps, Contacts, Leads, and Campaigns

<apex:page showHeader="false" sidebar="false">
<apex:pageBlock >
<b>Enter search term: </b>
<apex:form >
<script>
function doSearch()
{
    var searchStr = document.getElementById('txtSearch').value;
    window.open('/_ui/common/search/client/ui/UnifiedSearchResults?sen=001&sen=003&sen=00Q&sen=006&sen=701&str=' + encodeURIComponent(searchStr), "_parent" );
}
</script>
<input type="text" id="txtSearch"/>
<input type="button" value="Go!" id="btnSearch" onclick="doSearch()"/>
</apex:form>
(<strong>NOTE:</strong> Only searches Accounts, Opps, Contacts, Leads, and Campaigns)
 </apex:pageBlock>
</apex:page>

3) Finally, go to setup > customize > home > home page components.  Create a new HTML area left sidebar component.  On the screen where you can enter in the HTML, make sure you select the checkbox "Show HTML" and then paste the following (this references your visualforce page and displays it in the sidebar):

<IFRAME height=150 src="/apex/advancedsearch?core.apexpages.devmode.url=1" frameBorder=0 width="100%"></IFRAME>

4) Add the custom component to your pagelayouts and test it out! 

I created a custom object and want to create a trigger that takes the value from one field to another field on the same object but the field to be populated by the trigger is a required field.  I'm against this because it's going to be the same value but that's what the boss wants.

 

I found a piece of simple code that populates a field when a new record is created and saved.  I have tweaked the code and it does populate the field, but since the field is required I have to type in any value first then when I save the record it populates with the correct value from the other field, hence my question can a trigger work on a required field where I don't have to type in a dummy value first.

 

I'm not a developer and my knowledge of Apex is basically finding sample code and trying it out to see what it does and then trying to tweak it, same with vocabularies.

 

Required field is "Profile Name" to be populated with same value as field titled "Solution"

 

Any help would be greatly appreciated

 

thanks