function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

how to have a constant value that does not get updated each time the parent object changes

I want the field to derive its value from the parent object when its first created but not permanently linked, that is it should be a snapshot in time. so if the parent object is updated  it should not be updated but should have the old value of the parent object.





Ritesh AswaneyRitesh Aswaney

Use a workflow field update which will copy across the field from the parent at the point in time when this record is created. it will then remain a snapshot, not linked to the parent.


to summarise,

workflow rule on child, triggers on create only

field update action : copies across field from parent to child 


Thanks for the reply,

so that means the field is set as just a number field and not a formula that would derive from the parent object, so the trigger goes once the object is created and  the value is set.



Ritesh AswaneyRitesh Aswaney

That is correct, just a normal text / number field, not a formula field. Populated using a workflow field update, thus effecting a snapshot, rather than a linked update.


Ok I set the field as a number field without any value and created the a work flow  with the evaluation criteria is  Only when a record is created and gave the formula as


TSN__c  =  Aircraft__r.TSN__c


but it doesn't seem to work... i wonder what went wrong?


OR should it be done when the event is created the field gets updated?

Ritesh AswaneyRitesh Aswaney
If your criteria is only when the record gets created then hopefully you are creating a new child record and setting a parent record which has a not null value in the TSN__c field. Just to double check that the workflow rule is on the child object and has a field update to set the field from the parent. Relationship fields are not accessible in before trigggers. I'm wondering id this is a similar case. I would also try creating a formula field to hold th aircraft.tsn__c and then use workflow field update to stamp the value from the formula field on the child to a static number field.

creating a formula field to hold th aircraft.tsn__c and then use workflow field update to stamp the value from the formula field on the child to a static number field does not work as being a formula field its not accessible from the workflow,


but yes its working fine when its number field with workflow update field...

but i was wondering would ISNEW() and PRIORVALUE() functions help in these situations??

thanks for the help


I still didnt get to solve my problem.. Using a formula field to derive the value from the parent object does not set the value to be static as each time the field is updated in the parnet the value changes in the child object which is not required as I want to have the first instance of the child to be saved in there. Using the text field I can set it tob static but I dont want it as an input field where it prompst the user to enter a digit and once created it derives the value from the parent object.


I need the field like formula field a uneditable but can be set to static like a text using the workflow on my child object any solution for that??

Ritesh AswaneyRitesh Aswaney
You could edit the page layout to make the field read only on the edit page. Possibly have a default value in the field like 'changed'. The workflow can then populate on save, and it will be visible correctly in the detail page layout.

I have set the field as a read only in th epage layout and default value of zero ,sorry it was a number field not a text field there no way it can be prevented from appearing in the input page only later on once the event or the obejct is created?



Visualforce page :)

Override New  button with visualforce page which has the exact look-and-feel of standard salesforce. In that VF page hide that field.


Can you please give a further explanation to it as I havent got a much expereince working on VF as am still a newbie to SF ^__^




Check these posts:


Build your visualforce page, then override the New button with that page [ Create - Object - YourObject - Standard Buttons and Links].


Sample VF page:


<apex:page standardController="SMS__c" >
<apex:form >
    <apex:sectionHeader title="Create Message" subtitle="New Text Message"/> 
    <apex:pageBlock mode="edit" id="pb1">
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!cancel}" />
    <apex:pageBlockSection title="SMS Information" collapsible="false" id="pbs1">
        <apex:inputField value="{!SMS__c.To_Lead__c}" required="true" id="lname"/>
        <br /><br />
        <apex:pageBlockSectionItem id="pbsi1">
            <apex:inputTextarea value="{!msg}" cols="75" rows="5" id="msgArea"/>

 Similarly you can create sections in VF page like that of Salesforce standard page.