I have created a custom Visualforce page for when a User is editing a task. I also need to create one for when a User creates a new Task. The pages are almost identical except there are some extra fields in a separate PageBlockSection that are available in the Edit page that aren't available in the New record page.

Is it possible to create only one page and Hide or Show sections depending on if it is an edit or a new page?

1 Answer 1


Yes, assuming you are using standardController="Task" for the vf page, you can check to see if the record's Id has been set. If not, then it is a "new" record.

<!-- Don't show unless it is an existing record -->
<apex:pageBlockSection rendered="{!NOT(ISBLANK(Task.Id))}">

  • I am, I also have an extension that gathers that data for a couple of fields. Thanks!
    – Mike
    Commented Jun 2, 2015 at 16:46
  • Another question, If I wanted to only display if Task.Id is null, I'd just remove the ! correct?
    – Mike
    Commented Jun 2, 2015 at 16:58
  • Nevermind, I am dumb. just needed to remove the NOT
    – Mike
    Commented Jun 2, 2015 at 18:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .