SharePoint Blog

How to create a SharePoint column that will launch a custom edit form

First, we will need to create a calculated column field in SharePoint. You can do this by going to List Settings > Create column

Second, we will need to give the column a name and select “Calculated (calculation based on other columns)” as the column type.

Next, in the Formula section, copy & paste the code below (exactly as it appears):

="<a href='javascript:var options=SP.UI.$create_DialogOptions();options.url=""CustomEditForm.aspx?IsDlg=1&ID="&ID&""";options.width=600;void(SP.UI.ModalDialog.showModalDialog(options))'><img src='/sites/someimage.jpg' /></a>"

CustomEditForm.aspx” is the url of the custom form you are linking to. Notice that because this is an edit form we also have to pass the list item ID as a query string parameter (this is also needed for a display form). You can replace “/sites/someimage.jpg” with the url of the image you want to use or replace the entire <img> tag with text for the link.

Lastly, we need to select “Number (1, 1.0, 100)” as the data type returned from this formula. DO NOT FORGET THIS STEP!

We also have the ability to customize the title, height, width, and other options of the dialog. Please see Microsoft’s documentation about the SP.UI.ModalDialog.showModalDialog(options) Method

 

Karl Jumblatt

Corebix

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*