I'm customizing the DisplayForm of a list, and I want put a button on footer to EditForm, but in the ctx has no edit form url and no CurrentItem.ID.

How can I do this?

  • 1
    ID can be retrieved from the Query String in URL – Asad Refai Nov 24 '15 at 12:47

Getting from ctx

var itemId = ctx.FormContext.itemAttributes.Id;

I have executed above code under OnPreRender & OnPostRender both. So you can use it where you need it.

I think it is easier to get from Query String rather than from ctx.FormContext.

As per Asad's comment, Getting from Query String

var itemId = GetUrlKeyValue('ID');

Have a look on this answer by Danny Engelman to read more about Query String.

| improve this answer | |
  • Which one you have used? query string or ctx.FormContext.itemAttributes.Id? – Atish Dipongkor - MVP Nov 24 '15 at 13:24
  • For now query string. But is good to know about FormContext.itemAttributes. :D – Carlos Nov 24 '15 at 13:25
  • Hey, u know how extract the user name from user field (ctx.CurrentItem.Author)? – Carlos Nov 24 '15 at 13:26
  • use console.dir(ctx) in OnPreRender and see what's in it. I just find it (ctx.FormContext.itemAttributes.Id) this way – Atish Dipongkor - MVP Nov 24 '15 at 13:28
  • Author is in ctx.ListData.Items[0].Author. – Atish Dipongkor - MVP Nov 24 '15 at 13:31

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.