Loading...

RE: Custom qlist Action Button

RE: Custom qlist Action Button

#5561
Anonymous
Anonymous
Participant

This is the code

public ActionResult Perform(CustomActionContext context, CustomActionCancelEventArgs evt)

        {

            ActionResult actionResult = new ActionResult();

            if (context.Items == null || context.Items.Count == 0)

            {

                evt.Cancel = true;

                // you may construct a simple message for popup message or html text if message will be shown as inline

                evt.Message = "There is no item to validate.";

                return actionResult;

            }

            SPListItem item = null;

            StringBuilder itemIDs = new StringBuilder();

            IEnumerator enumerator = context.Items.GetEnumerator();

            while (enumerator.MoveNext())

            {

                item = enumerator.Current as SPListItem;

                if (item != null)

                {

                    itemIDs.Append(item["ID"] + ";");

                }

            }

           

            actionResult.RawData = itemIDs;

            return actionResult;

        }

This is the custom action

<CustomActions>

  <ContextMenu />

  <Toolbar>

    <ActionItem ID="SelectID1" Text="SelectID/Delete">

      <Action Name="Action1" Type="Custom" OpenURL="CurrentWindow" class="MyCompany.DevStudio.pleCustomActionEx, MyCompany.DevStudio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=451cac61f7ec4225" />

      <Action Name="Start" Type="GoToURL" URL="http://sp22:63/default.aspx" OpenURL="NewWindow">

        <Parameter Name="OrderID" Source="ResultFromAction" SourceName="Action1.RawData" />

      </Action>

    </ActionItem>

  </Toolbar>

</CustomActions>

and teh list is a custom list with no extra fields.

Please let me know how it goes.