Programmatically inserting/removing buttons and corresponding event handlers in InfoPath at run time

S

soumitra.mishra

Here is what I want to achieve. In my InfoPath form I am getting some
data from a web service. Based on this data I need to
dynamically(programmatically) insert buttons on my form. In addition to
this I also want to link these buttons to correspoing click event
handlers which would contain some code (namely to delete an item from
SP site). I will describe the actual senario to give a better idea of
what I am trying to achieve.

In my InfoPath form I call a web sevice which returns a list of
documents on a SP document library. I display this list on my form (as
a list of document names). Now I need to add corresponding buttons
through which I could delete the corresponding document from SP
document library. As you can see this requires me to dynamically create
buttons as well as their button click event handlers and then hook the
two together - remember all at run time. Just to let you know - in the
button click event handler (vbscript function) I will call another web
service that will delete the corresponding document from the document
library. After doing this I would like to remove the corresponding
document row including the button from the form. Seems like I am asking
too much from poor InfoPath. But I hope some of you experts might have
solution/hack to my problem. If you do then hats off to you.

Thanks,

Soumitra
 
B

Bojana Marjanovic [MSFT]

Here's a stab at it:
Create a repeating table with one of the columns containing the button that
will be doing the deleting. Write an onClick event on the button that
accesses the form name that the button is trying to delete. Keep in mind
that you'll have to pass the form name based on the location of the button.
Then do the deleting.
You'll most likely have to copy over the list of items from your web service
into the main DOM.

I'm not sure if this will do the trick for you or not. Let me know how it
goes.

-Bojana
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top