0

I am trying to change the createddate of a feeditem object using input from the user. What is happening is that, it is working perfectly for System Administrator profile, however for any other profile, the inputfield is showing as blocked, in the UI popup(from where the user was supposed to enter the date value). I have the following piece of code

<apex:pageblock>
    Add comment: <br></br>
    <apex:inputTextarea value="{!AModel.Comment.Body}" rows="3" cols="80" />
    <apex:commandButton action="{!AModel.saveOnBehalfComment}" value="Save" id="saveCommentButton" />
    <apex:pageblocksection>
        <apex:pageBlockSectionItem id="DateTimeofComment">
            <apex:outputLabel>Sent Date</apex:outputLabel>
            <apex:inputfield id="Date" value="{!AModel.Comment.createddate}" />
        </apex:pageBlockSectionItem>
    </apex:pageblocksection>
</apex:pageblock>

In the class I have the following piece of code.

private Transient FeedItem pComment = null;
public FeedItem Comment {
    get {
        if (pComment == null) {
            pComment = new FeedItem();
            pComment.Type = 'TextPost';
            pomment.Visibility = 'AllUsers';
        }
        return pComment;
    }
    set;
}
public void saveOnBehalfComment() {
    Some other code................
    update Comment;
}

I do not know if its is possible to give a permission to the profile on createddate of feeditem

1
3

Some of the System fields are not editable. So in other words you can not modify createddate of record. This done by design and there are few exceptions for while performing data migration Salesforce support can allow you to update created date or last modified date for few days but in general its not not mean to be edited by user. If its Critical business requirement for you then you will need to create your own custom datetime field and remove createddate from all layouts and show your custom field with same label.

Here is complete list of field for your reference.

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_system_fields.htm

Out of these fields Id , CreatedDate, LastModifiedDate, & SystemModstamp are not modifiable.

4
  • is there any other way I can pass the data given in the inputfield by the user, to the controller class @AtulRajguru9
    – Rimii
    Jun 7 '16 at 9:48
  • your commented question does not make sense in context of OP. but in general.. yeah, you can create new field on your controller and pass data in that. Jun 7 '16 at 12:41
  • no where in my answer(or in question) we talked about Audit fields then why are you mentioning this here. Jun 8 '16 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.