Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to modify data in a ConfiForm using and Edit Control macro with JavaScript

Edited

I'm trying to modify fields within a ConfiForm based on the values of other fields using the Edit Control.  Specifically, I'm trying to update the hours a user scheduled to work on a specific project for a certain range of weeks.  I have tried using IFTTT macros with the onModified event.  However, I haven't been successful at getting access to the Form.  That seems strange, since the form defintion is on this page.  I have also tried the Run custom JavaScript option with SetValueFunc(formName, formId) on the Rules for Field Definitions, and apply them to the 3 fields that matter in the calculation (I've also tried all of the fields), but I get strange results.  For example, if I change the hours for myself for weeks 15 - 30, sometimes it works, but sometimes it just updates the rest of the fiscal year with the new hours.  Sometimes I change the scheduled hours, but it doesn't update, so I change it to a different number, but it then updates it with the 2nd number I entered - kind of 1 behind on the form entry.  I need this to update correctly every time.  I started with using the REST API, but that won't update on the TableView macro that shows all of the data of all of the users.  I need all the data to update accurately every time.

Thanks,

-Kathleen

1 answer

1 accepted

1 vote
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 06, 2023

Hi @Kathleen Janiszewski and welcome to community

I will try my best, but honestly - I am very puzzled with your question

Seems to be a mixture of client side and server side things

So, you can update ConfiForms records with ConfiForms IFTTTs (server side) and you can also use REST APIs to update ConfiForms records from a client side

These are different approaches/methods on how to do a similar (or same) thing - should not be used together (and are independent from each other)

Alex

Alex,

Let me explain what's going on.  I start with a ConfiForm that has a user, number of hours per week, and a list of start weeks and end weeks in the fiscal year.  An admin can at any time change the number of hours per week a user is assigned to their project for a given time frame by week.  Based on the selected weeks, I know which ConfiForm fields need to be updated.  This is where I construct the string that's used in the REST API.  If you have a more direct way for me to be able to update the data directly via the IFTTT macro, please let me know!  That's what I've been looking for.

Thanks.

-Kathleen

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 06, 2023

What is the easiest for you. If you find the REST API call easier then do that

I think using the Create/Update ConfiForms Entry or Update Entries by Filter IFTTTs is easier to use and work server side, which means - always (even when updates are invoked from automation, etc)

Alex

I would much rather do this using the "Update Confiforms by Entry".  I initially tried that.  The limitation is that I need to build the list of fieldnames.  Fine, I've done that plenty of times in JavaScript.  So now, depending on the weeks the user has selected, say weeks 30-45 (i.e., [entry.startweek] is 30 and [entry.endweek] is 45), I only want: "week30=[entry.hours]&week31=[entry.hours]...&week45=[entry.hours]".  This string is pretty easy to create in a loop.  How do I get this into the "Parameters to set on the entry field?"  Is there a way to use the "Set custom name for this action result?"  That's all I see as a field on the ConfiFoms IFTTT Integration rules macro when I select Run JavaScript.

Thanks.

-Kathleen

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 07, 2023

Hi

If you need to build the parameters dynamically then you better stay with REST APIs

Alex

Like Kathleen Janiszewski likes this

Alex,

So now I have the ConfiForm storing the correct data, using the REST API.  Now, I need to force the refresh of the TableView macro.  How can I accomplish that?  I tried adding another onModified IFTTT macro that redirects to the current URL, but that doesn't always work for all of the data.  It's probably an issue with synchronicity.  Please let me know if there are any other options. 

Thank you.

-Kathleen

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 07, 2023

Hard to tell what does not always work... without seeing complete configuration, but

If you do everything in JavaScript then I believe there is no need to switch to IFTTT to do just a redirect

You can do the redirect in JavaScript as well. using document.location = 'some url';

Alex

Alex,

Using location.reload() in the javascript after an update puts me in an infinite loop of re-executing the javascript in the IFTTT macro.  That makes sense though, since once tableview macro is updated with the new data, it's considered an 'update' and fires the IFTTT macro again.  Is there any way to force the update of the data within the TableView macro?

Thank you.

-Kathleen

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 08, 2023

If your IFTTT runs onModified and does not have any condition set then it is a problem.

Your IFTTT should have a condition or catch the transition and not run every time on every update

Alex

The user would only edit and not cancel out unless they modified something, so there's no good reason to have a condition set.  If there's some flag that is set when something changes on the form, that might work.  Otherwise, my initial approach was to do all of this on the initial update form.  Hence the question I pose here: https://community.atlassian.com/t5/Confluence-questions/How-to-use-data-on-a-ConfiForm-to-update-hidden-fields-prior-to/qaq-p/2293599

I'm kind of at the point of giving up on ConfiForms and just do everything in JavaScript with a  Tabulator in lieu of a the TableView macro, and a modal dialog box to server as the form for updates.  I know that will work.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 08, 2023

Well it all depends on what you feel more comfortable with and what is the best tool for the job

From fragmented requirements I read from your posts I feel like this is not really a job for ConfiForms. 

As this is some very custom form that you need to do lots of precalculations.

Anyway 

If there's some flag that is set when something changes on the form, that might work.

You can set one extra field that will tell you such "flag" And never do an update when this field is matching

See this page https://wiki.vertuna.com/display/TEST/Send+email+when+action+button+is+clicked

We send an email only when send field has a true value and only when it changes to true

We have an extra ifttt that resets the send field value after that

Alex

Like Kathleen Janiszewski likes this

Alex,

Thank you for your help.  You might be right.  I do have to use ConfiForms for parts of this project.

Thanks!

-Kathleen

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events