Friday, July 23, 2021

Working with igloo, variables, and coding

 I've been asked to setup an email form to tie into Igloo, and for the most part setting up Igloo for a SAML connection was pretty easy, (I'll do a post on that later) but for this email form setup getting some of the variables out of igloo was more tricky; especially since I am not to familiar with the platform, or how it works.  I hope this post will help other coders who need to do work on an igloo system without having to get the developer account or just found it as frustrating as I did trying to break the system down.  I haven't come across a good document for how to do these particular kind of things on Igloo's site but you do have to be approved by igloo to access customer care and the developer section of the site.  In my option they don't have a good web only quick start guide.  So I hope this will help some users of the platform.  If you don't have a igloo login, the only thing accessible is the guides-ebooks page on their website.

https://www.igloosoftware.com/resources/guides-ebooks/

So you have to have an account (probably with admin access) to get more info and access to the igloo support forums.  When your logged in you will see something like this menu.


If you go to the Igloo support link, you will get to see the following resources.

Developer KB

https://customercare.igloosoftware.com/support/developers/kb

Community Forum

API Reference

https://customercare.igloosoftware.com/support/developers/api_reference

For working just with a webform and trying to get some info from the user to me wasn't very intuitive and working with the platform wasn't intuitive but it is workable once you know how things are done.  Now a requirement for this form is that I can't use an iframe, and needs to be native to igloo.  So in this case the email form was setup as a start it was setting up an email form, where it sends data to a helpdesk system but I don't want the user to have to type in their email again because they are logged into the intranet and I should be able to get this information.


So after doing a lot of googling I came across an obscure reference on the community forum.  https://customercare.igloosoftware.com/community/developer_questions/is_there_a_quick_way_to_get_the_current_user

So not being familiar with igloo I looked at the comments, and seen the question about referencing the object (since I wasn't using the API) I thought it was referenced though the WYSIWYG editor like some other CMS/LMS systems.  I was wrong.

So I tried using {Igloo.currentUser.id} in the HTML page where the form was, and that didn't work.  nothing was displayed and I couldn't get/find any kind of documentation for what I was looking for except from this reference.  I gathered that I had to probably use javascript to access it; however the way igloo is setup you have to really plan how you want to work with.  After viewing source and finding this snipe of code.


 I figured that I have to be able to access this the same way I just have to figure out how to use javascript to access the info.  I found it is best to work in two tabs when doing this in Igloo.  One to have the HTML editor open, the other to have the javascript editor open.

HTML Editor

Javascript Editor


  So I did a test with document.write in the javascript editor in igloo. which broke the page I was working on but I did see the variable get written to the screen!  Yay!?

document.write(Igloo.currentUser.id);

So after setting up some HTML elements I came up with this.

document.getElementById('name').setAttribute('value',Igloo.currentUser.name);

document.getElementById('userid').setAttribute('value',Igloo.currentUser.namespace);

//Display just the first name. (does a split based on the space in the name)

const title=Igloo.currentUser.name;

const firstName=title.split(' ')[0];

document.getElementById('staffName').innerHTML = firstName;

This javascript allows me to get the email because the email has the same convention as the namespace, I can put a note with the user's name with instructions or a note for the email form when they land on the page.


So in short, for any web dev's who are just throwing something together quickly, here are the igloo JavaScript variables for getting some user info.

Igloo.currentUser.name

Igloo.currentUser.namespace

Igloo.currentUser.href

Igloo.currentUser.id

Igloo.currentUser.hasphoto

Igloo.currentUser.memberkey


How to migrate PFSense Over to KEA DHCP Server from ISC DHCP Server

I am a PFSENSE User and I manage PFSENSE for some other organizations and the time has come to make the switch for the DHCP Server over to K...