What kind of field to use in an Appian interface for a system updated field to store data without needing users to gain focus of the field - appian

My question is:
What kind of field would you use in an Appian interface to display [but not allow editing] of a field like "created by" and "created date" that you want to display but not allow user editing - such that the data from these fields is actually stored into the database.
Details of issue:
My colleague and I are fairly new to appian development and are working on a problem.
She created an interface that that allows us to add and edit the rows in a particular reference table.
The interfae [mostly] works - in that it allows you to add and edit rows in the database table.
The problem we have however is that there are some fields, which are not supposed to be directly edited by users. For example:
"Created by"
"Created date"
Rather than the users adding values for these fields, we want them to be automatically set by the system by retrieving the currently logged in user and the system date.
My colleague has been able to set the field values to their initial states using the loggedInUser() function and the now() function.
a!textField(
label: "Created by",
labelPosition: "ABOVE",
value: if(ri!RefDataTable.referenceId, ri!RefDataTable.createdby , loggedInUser()),
saveInto: a!save(ri!RefDataTable.createdby, upper(save!value)),
characterLimit: 255,
)
and
a!localVariables(
local!storedValue1:now(),
a!dateTimeField(
label: "Created Date and Time",
value: if(ri!RefDataTable.referenceId, ri!RefDataTable.createddate, local!storedValue1),
saveInto:{
a!save(ri!RefDataTable.createddate, local!storedValue1)
},
)
)
However, it seems that these values are not transferred into the database unless the lose-focus event is triggered for the field, which causes the method recorded against the "saveInto" field to be executed.
So it becomes necessary for the user to manually click on each of these fields and then out of them again for the values to get into the object that will then be stored into the database. If this is not done, then even though the form appears to save the record, it does not actually save any of the data at all.
I am thinking that perhaps some field type other than a!textField() should be used for the "created by" fields. Further, perhaps some field type other than a!dateTimeField() should be used for the "date created" fields - since we don't actually want the user to edit these - but rather we simply want to store the values extracted from the system into these fields.
However, to date, we have not been able to figure out how to capture the point at which the data is stored to the database so that we can [simply] store the values into the database [presumably via the CDT] at the point the record is stored.

You should not write to the db from an interface it is very difficult to follow data if you do.
The recommended solution is to pass the values captured in the interface upon submission and pass it along to process variables and perform the db updates in another node in the process.
avoid a!writeToDataStoreEntity() if you are not experienced.
a!localVariables(
local!currentUser: loggedInUser(),
a!formLayout(
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!textField(
label: "Customer",
value: ri!customer,
saveInto: ri!customer,
readOnly: false
),
a!textField(
label: "User",
value: local!currentUser,
readOnly: true
)
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
submit: true,
saveInto: {
a!save(ri!currentUsser, local!currentUser)
}
)
}
)
)
)
regarding the date issue you can display one date in the interface and insert another into the database just create an script task right before writing to the db and write that date instead. This is one technique among others.

Related

Im trying to update a long textbox in my db using an update qry, bt anytime I click on the btn to open the qry and input the value it overite the pre

I have a table called student and a field in it called miscellaneous. So any items given to the students should appear in the miscellaneous field. So I created and update query with field=miscellaneous
Table= students and update to =[""]&[""]
So on the form I created a btn to run the query and it ask for the value for [""] and after inputting the value and wants to add another one it overwrite the old one.
Will be glad if someone have seen this before

React-Final-Form: Set initialValues from props, form state resets on props change

I have a component, that takes a balance prop, and this balance prop can change over time.
I then have a React Final Form to send a transaction, with usual fields amount to send, receiver... And in my validate, I just check that the user has enough balance to send the transaction.
However, if my balance changes when the user is inputting something, then the whole form resets. How would you only reset part of the form state?
See this codesandbox for an example: https://codesandbox.io/s/jn69xql7y3:
input something
wait 5s
see that the form state is blank again
I just ran into this issue with react-final-form where the form completely resets when any state change happens in a wrapping component.
The problem is here (from your codesandbox)
<Form
initialValues={{ amount: 0, balance }} <-- creates a new object on every render
The problem is that when initialValues changes the entire form reinitialises. By default, whatever you pass to initialValues is compared against the previous one using shallow equals, i.e. comparing reference.
This means that if you create a new object in the render, even if it's the same, the entire form resets when some state changes, the render function re-runs, and a new object with a new reference is created for initialValues.
To solve the general problem, if you just want to turn off the form resetting, what I've done is just move my initialState, which never changes, out to a variable so that it's the same reference on every render and therefore always appears to be the same to final-form with the default behaviour. I would prefer a configuration to actually completely turn off this reinitialisation behaviour, but I can't find one in the docs.
However if you actually want this, but need to modify it, the comparison behaviour can be configured using the initialValuesEqual prop (docs here), to do a deep comparison on the initialValues object for example.
You can also use the keepDirtyOnReinitialize prop to only reset the parts of your form that haven't been touched.
I would guess some combination of the above might solve your usecase, depending on the exact UX you need.
Adding onto what #davnicwil mentioned, my solution is useMemo() hook in func components:
const initialValues = useMemo(() => ({ amount: 0, balance }), [])
By using useMemo it creates only 1 object during the life of the component and subsequent re-renders don't cause initialValues to overwrite the form values.
Another solution is to use react-final-form Form prop initialValuesEqual={() => true}
<Form initialValues={{ amount: 0, balance }} initialValuesEqual={() => true} .../>
ref: https://github.com/final-form/react-final-form/issues/246

Archer to Archer Data Feed in RSA Archer

Need to create Archer to Archer Data Feed that should set value of two fields as NULL in a cross referenced application, if the value of a field is Approved in first field. I am not getting how can I send a NULL value to the fields through data feed??
Archer doesn't have "NULL" value, but you still can get it done like this:
Step 1. Calculation. Open your data feed configuration and go to the source definition tab. Add a new field to the end of the list and make it calculated.Add formula to check value of 1st field that present in the data source and if it is equal to "Approved" then return empty string.
Something like this
=IF([field field] = VALUEOF([first field],[Approved]), "","SOMETHING ELSE")
The key here is to have this calculation return an empty string when you need it - "".
I suggest you to test your calculation in the calculated field in the application before you put it in the calculated data source field.
Step 2. Data feed mapping. Now you need to map new calculated field in your data feed to the field you want to remove value from. Go to the mapping tab in your data feed configuration and map the field. Make sure to selection options "Replace value" and "Empty Values" - this way existing value will be replaced even with empty values.
Similar approach works for me in multiple data feeds.
Good luck!
You can use novalue() function in the calculation
I don't believe there is a concept of NULL in Archer. The closest you're probably going to get is blank/empty. To do that, in the Data Map tab of your data feed, click the edit icon under Actions column. Check the box that Empty Values should be populated rather than ignored.
Assumption is that what is in the question is the only task required by the data feed.
Create report with the filter set as First Field = Approved
Fields to display should contain tracking id (tracking ID which is configured to System ID) of the Target app along with the Tracking ID of the Cross-Reference App.
In Source Definition add new source and give it an adequate name as clear or Null if you want
Where it says Raw Data Field in the drop-down, update this to static. Leave the source as not configured or unconfigured.
Map this newsource to the 2 fields that you are trying to clear. In Options set to Replace and uncheck add unknown and set to populate empty values.
Map the Tracking ID of the Target app and map the Tracking ID of the cross-reference.
Set key field definition for both apps to the tracking id
Set data feed to update only. Remove checkmark for create
If your are doing more than just clearing the 2 fields, then
Stan Utevski answer is mostly correct except you must have the field you are evaluating for "Approve" in the fields to display of your report. Otherwise the calculation will not validate.

Breezejs non scalar complex type not updating properly when refetched from server

We are running into an issue with updating non scalar complex type.
Our simplified metadata looks like this
Table
shortName: 'Table',
defaultResourceName: "/table",
dataProperties: {
name: { max: 50, required: true },
description: { max: 500},
columns: {complexType: 'Column', isScalar: false}
...
}
Column
shortName: 'Column',
isComplexType: true,
dataProperties: {
name: { max: 50, required: true },
description: { max: 500 },
...
}
Our backend is document based nosqldb.
In the UI, we display all the tables and its columns in a tree like structure. User can click on a Table name or column and edit it's properties in a property editor. Table and Column have separate editors, even though internally they are part of the same object.
Initially when we display the tree we only fetch limited no. of dataproperties of the json, only the ones that are required to be displayed in the tree. But when the user clicks on a particular table or a column we fetch the entire table (columns are complex types) from the server and update the cache to display them in the editor.
We are using knockout as the model library so all the properties are knockout observables. We are passing the same breeze entity objects to viewmodels of these editors as well as the tree.
If the user clicks on a table in the tree, and edits name or description in the editor, we are seeing table name in the tree is also changing as it should, since they are both the same observable. But when I click on a column name in the tree, and edit the column name in the editor, I do not see the change getting reflected in the tree.
What I think is happening here is, when I am re-querying the same object from the server to display in the editor, table name which a simple property is being updated with the new value from the server, but column name which is part of complex object, is actually getting replaced with new values from server, since each complex object in the array itself is being replaced. So it seems like tree and editor has different obsrevables.
Funny thing is, if after clicking on a particular column and having it displayed in the editor, I move to a different module (we are using spa), and then come back to the original module again, then if I click on the same column again and update the name, this time the change is getting reflected in the tree. But not the first time.
Could this be a bug, or am I missing something? Is there a workaround?
We are using breeze js 1.5.6
Thanks!

FIELDS_CHANGE mutation with connection field

I'm trying to understand how Relay works.
1.) Let's say I have UpdateProductMutation (FIELDS_CHANGE type) that updates fields of single product i.e. 'title', 'description', etc. I can send mutation with those fields changes and it works. (Say the product here is Banana)
2.) Now I add product_categories field of type ProductCategoryConnection to the Product type. And in the UpdateProductMutation mutation, I send "catIds" array as additional inputField of the mutation. (i.e. catIds: {type: new GraphQLList(GraphQLID)}) It also successfully mutates the Product with the product_categories field.
3.) To make it easier to follow, let's say Banana product had Fruit and Yellow categories. And I've added Healthy in step 2.)
4.) Problem is, if I've queried Healthy page before step 2. and Relay already has the cache in store, visiting Healthy page again after step 2. doesn't show newly associated product, Banana.
This is my mutation config and fat query.
getFatQuery() {
return Relay.QL`
fragment on UpdateProductPayload {
updatedProduct,
}
`;
}
getConfigs() {
console.warn('getConfigs', this.props);
return [{
type: 'FIELDS_CHANGE',
fieldIDs: {updatedProduct: this.props.id},
}];
}
I'm not sure if I understand it totally wrong. It seems like FIELDS_CHANGE is not the correct type to use here because the mutation works fine and the mutation payload gives the changed product category edge. The problem occurs only when I go to the previously fetched related product category page and don't see the updated product there. (Relay doesn't even send the query again). From my understanding, RANGE_ADD or RANGE_DELETE don't allow you to change the normal field either (i.e. 'title', 'description', etc.) Also in my case, catIds array could either cause RANGE_ADD or RANGE_DELETE, depends on the selection on the page.
Any advise on which direction I should take?

Resources