Home Analyst Portal

v8.8.1 Send Email: How to programmatically set TO and CC?

Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
The new Send Email task is better in most ways, but the old one was much easier to manipulate with custom code.  I think I may just be missing something in my approach, so I could use some help with this.

The TO and CC fields are now Kendo MultiSelect controls, and there is much documentation out there about how to set the value of one.  The very brief version of this is myControl.value(['big-scary-guid-for-first-person','big-scary-guid-for-second-person']);.  Some apparent caveats: the value (guid in this case) needs to be part of the filtered list (the list that appears if you start typing in the field) which for it to match, and most pertinent to my question here, there is apparently some event that needs to be triggered to get the new value to show up on the screen.

I have been successful setting a filter and adding the value to the control, and I even see my selected value in the DOM (Kendo controls always maintain an old-school HTML control in the background and I can see my value get selected in the <select> tag), but the screen never gets updated.  What am I missing here?

Here is my approach so far (just using TO for now) in pseudo code, to help answer the question:

toField.dataSource.filter({
      field: 'Id',
      operator: 'eq',
      value: pageForm.viewModel.ContactPerson.Id<br>      // ContactPerson is a custom relationship--substitute affected user (RequestedWorkItem) for the same result<br>});
<br>toField.listView.setDSFilter(toField.dataSource.filter());

toField.value([pageForm.viewModel.ContactPerson.Id]);<br>//In practice, you would merge the new value with the existing array , but I'm leaving that out for brevity<br><br>toField.trigger('change');<br><br>// Behold!  Absolutely nothing changes on the page!<br>var toField = $('select#userPickerTo').data('kendoMultiSelect');<br><br>toField.dataSource.filter({});<br>

This is based heavily on some of the Kendo docs.  When I attempt something similar in JSBin or Dojo it works, but not in the SMP.  What's different?

Best Answers

Answers

  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    I had considered this, @Jeff_Lang, but I held off because of my uncertainty about the Email property.  Is it part of the items in the datasource along with Name and Id? Is it used to address the mail, or is that a separate lookup that takes place?  It seemed better to just ask the community.

    However, the fact that you brought this up is helpful, and I appreciate it.  You've pushed me over to this line of thinking again, and I am going to test it.  After a few days of no other responses, I think the time to test this out is going to be worth the effort, either way.
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    Update:  this approach appears to be successful.  I am now testing to make sure that the emails send properly, but I am marking this answered since the names are appearing in the correct TO or CC box according to our business logic, now.  Many thanks!
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    I think this was a case of looking at it too long.  I was almost 100% certain there was a 3rd property called "Email," which is what had me wondering how/where it was used if the value was just the ID.  Now I can see that this extra property is not part of the data source but is added in another object by the controller.

    However, success here has lead to the next challenge.  The form is now populating correctly, unless it is closed and re-opened.  The values are still correct in the background, but the fields appear blank to users.  This is worse than if they were truly empty, since the email could contain unknown/unintended recipients.  My attempts to get the fields to show the selected users have so far not succeeded, even when I clear everything out and start over.  So as long as the analyst clicks the task once and never again this is fine, but opening the form more than once spells disaster.

    I am continuing to try to figure this out, but I definitely welcome any other good ideas!
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    Some quick testing has proven this correct.  I think I have this fundamentally solved (more like worked around, to your point) now, although still trying to polish it up a bit.  Thanks for pointing me in the right direction!
  • Robert_OsterbergRobert_Osterberg Customer Adept IT Monkey ✭✭
    @Tom_Hendricks care to share your final findings?
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    I do not have anything shareable yet, or I would.  I am still seeing some strangeness on anything other than the very first load of the form.

    Also, I am using custom user fields that you will not have on your form (and checkboxes which determine who goes into TO and who goes into CC), so I would need to strip all that out to make it meaningful to anyone else.  I will try to do that as time allows, but first it needs to work properly every time I click the task...
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    To add to this, it is a good thing that I have still not pushed this into production.  The usability is a mess and it is hanging on to email addresses that the user thought they removed.  I have finally figured out how to get the fields to update correctly, but any interaction from the user wipes out the other field.  i.e.: if I programmatically update the TO and CC fields, that works fine, but if I then click into CC and type an additional address into it, it clears out the TO field (in the interface--the value still exists in the background, which is very dangerous).

    I am a big fan of the overall design of this new feature, but it has turned out to be nightmarish to customize.  (Nothing new, just the same as we were doing with the old form).

    It appears that it will be a while before there is anything to share.
  • Tom_HendricksTom_Hendricks Customer Super IT Monkey ✭✭✭✭✭
    Update:  I did eventually fix this, but the latest version of the portal (8.9.3) also works a bit differently behind the scenes (filtering, etc.), so I have to update again.  So far it is looking good, but more testing is needed before anything can be shared.
Sign In or Register to comment.