Posting user data to a new datasource

Hi all,

I need a little help getting started,I am trying to create the following experience.

We have a data source that has a number of available job roles/projects that are available, we are looking to introduce a button on a job role that is “register interest” this will then be written to a todo list for a member of our team to follow up on,

So I need to write (to a new datasource) details about the project they have selected and details about the current user.

Is there any help I can look at on how to get started?

Hi Barry,

We have a post on the community on adding a button to an LFD. See here.

You can use the button to direct the user to a form that then adds the information to a data source.

Using the LFD component you can enable this new data to update the list creating a to-do list.

See this article for editing a data source using a form.

Thanks Mel.

How do I refer to the current item in the list they have selected,

I assume its similar to Formbuilder.get(), but wondering how I refer to the selected list item.

Fliplet.FormBuilder.get()
.then(function (form) {
// Get the field with name ‘email’
var field = form.field(‘email’);

// gets the input value
var value = field.get();

});

Hi Barry,

Just to clarify from what component are you trying to select something from? For e.g a form or LFD (List from data source).

Thanks,
Deb

Hi Deb,

I have a LFD and I want to pull data from the selected item (for example date added) into a variable so I can write it to a data source.

image

Hi Barry,

Thank you for clarifying.

The steps you need to take are:

  1. Add a button to the detail template in the component HTML for this LFD.
  2. Assign some HTML attribute to this button so you can retrieve it using a click event.
  3. Connect to the data source you want to write to and add the data.

An example for No.1 can be found on “Current challenges” screen in the Innovation management template.

In this template we are storing the data-title attribute but you can also store {{id}} in the HTML. For e.g.

<div class="btn btn-secondary" id="{{id}}">Button Text</div>

This can return all the data associated with the chosen entry instead of one attribute. To get all the data you need to connect to the data source and grab the data for that ID using this: Data Sources JS APIs | Fliplet Developers Documentation

To do No.2 you can use the jQuery click event as shown in the Innovation management template.

To do No.3 you need to use our data source JS API to connect and write data: Data Sources JS APIs | Fliplet Developers Documentation

You might also need the update function if you are updating entries in your data source. It all depends on your use case.

Hope this helps,
Deb

Thanks Deb, got that working.
Last one, any easy way to get the email of the user in a variable?

Are you referring to the email of the logged in user? If so then you can use this to get the logged in user: Session JS APIs | Fliplet Developers Documentation