It's all about the answers!

Ask a question

Fill in Work Item without Template!?

Dave Evans (1382139) | asked Oct 16 '18, 9:27 a.m.


Is there a way to use a URL parameter, or a cookie or whatever that will open a work item with some fields filled in?

We'd like to simplify the creation of a work item for a project where the users can submit change requests. We want to have a link on a dashboard that shows a long description of "click here to submit an enhancement request for x, y, z". When the link is clicked, we want a work item to appear with the correct 'Filed Against' selected. 

We know about Templates, and we know how to make a URL link to the work item "Create from template" wizard... but the user will be faced with which template to choose. We'd rather not have to say "to create an enhancement request for x, y, z, click the link below and then select "X, Y, Z, Template". Maybe I'm seeking something that is too elegant...

One thought I had is... is there a way to get a URL parameter or cookie in a script-based calculated values?!? We could potentially set that up.

2 answers

permanent link
Ralph Schoon (61.1k33643) | answered Oct 17 '18, 2:41 a.m.

 For all I know this could be done using JavaScript and the OSLC CM API. You could, for example, create an open social gadget and that could display a button which allows to create a work item (using the creation factory for the work item type) and fills out the values as desired. 

Start here: 

Dave Evans commented Oct 17 '18, 12:57 p.m.

 Hmmmm.... we don't want to save a new work item, we just want a new (unsaved) work item to appear with pre-populated fields. 

Well if Ralph doesn't know how to do it, then who would? I decided to submit an enhancement for this:

Let me know if you think of anything else. Thanks!

permanent link
Nate Decker (37813058) | answered Oct 17 '18, 3:38 p.m.

I think I have a suggestion that might be possible. I had never considered it before, but it occurs to me now that it might be worth investigating. In fact, I'm pretty sure it would work actually.

We already have a Theme that includes some JavaScript that runs every time a page in RTC opens. The JavaScript in this theme adds the "309 SMXG Help" hyperlink to the navigation bar.

We could add another feature into this JavaScript so that it also looks at the URL in the address bar and if it contains the parameters we've defined, it puts the value of those parameters as text into the field in the work item if the fields are present on the page.

I just tested this to verify that if I add parameters to the URL, they don't get dropped from the URL when the browser navigates to the target CLM page and they DON'T. That surprised me. CLM clearly ignores those extra parameters, but it preserves them in the address bar which would leave them available for examination by the JavaScript.

Dave Evans commented Oct 17 '18, 4:32 p.m. | edited Oct 17 '18, 4:44 p.m.

Nate, you're a genius as always. I didn't think about customizing the javascript via the theme. I did confirm that the work item customization JavaScripts do NOT have visibility to the DOM, so I could not inspect the URL from there... but loading a JavaScript via the theme sounds like an approach I could get working.

Dave Evans commented Oct 17 '18, 5:59 p.m. | edited Oct 17 '18, 5:59 p.m.

Oh man, this is getting complicated fast. The text boxes and drop-downs are dojo widgets. The div ids are 2-3 levels up from the actual text box, and are (naturally) dynamically named. For example, the Summary box in 5.0.2 might be one level down from div with id "...RichTextEditorView_0", or in 6.0.4 it could be two levels down from "...RichTextEditorView_3". It is looking likely that I will hope that the RFE Community will see this as an easy win, and implement it for us.

Nate Decker commented Oct 18 '18, 9:25 a.m. | edited Oct 18 '18, 10:24 a.m.

 Ah, so it's complicated but perhaps only "easy" in a few rare cases (like direct text-entry fields then) eh?

It seems like maybe we could still make this work, but it does sound more complicated to implement than I initially thought.

One thing to consider is that the input field is always nested below the input label. So you could look for the HTML node of type "label" with a value of "Filed Against:" and then look for the first HTML node of type "span" with the class "ValueLabelHolder" that is nested below that label node. That should be the correct HTML element to target.

Ralph Schoon commented Oct 18 '18, 9:33 a.m.

I have never done this, but I believe you would have to use REST/OSLC to get the work item factory for the type. You would also have to use OSLC to get the attribute values you need to set e.g. category and what other required attributes are needed. 

I am not sure if you could use a delegated UI to show the work item before creating it. 

I am however not a web wizard. 

Please note that theme modification on that level should be done carefully. I know of at least one case where heavy customization of the theme with a lot of REST/OSLC requests to the server caused severe performance problems.

The Idea here is not what I would consider dangerous, but wanted to use the opportunity to provide a warning.

Your answer

Register or to post your answer.