Hi,
i've a portal with some users fileds. When i compile the fields on click button i want to save this fields in my appian db using post api (i want to test the API). I wrote this code for the portal interface:
=a!localVariables( local!nome, local!cognome, local!dataNascita, local!indirizzoResidenza, local!codiceFiscale, { a!textField( label: "Nome", value: local!nome, saveInto: local!nome ), a!textField( label: "Cognome", value: local!cognome, saveInto: local!cognome ), a!textField( label: "Data di nascita", value: local!dataNascita, saveInto: local!dataNascita ), a!textField( label: "Indirizzo di residenza", value: local!indirizzoResidenza, saveInto: local!indirizzoResidenza ), a!textField( label: "Codice fiscale", value: local!codiceFiscale, saveInto: local!codiceFiscale ), a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Invia dati", saveInto: { } ) } ) })
=a!localVariables(
local!nome,
local!cognome,
local!dataNascita,
local!indirizzoResidenza,
local!codiceFiscale,
{
a!textField(
label: "Nome",
value: local!nome,
saveInto: local!nome
),
label: "Cognome",
value: local!cognome,
saveInto: local!cognome
label: "Data di nascita",
value: local!dataNascita,
saveInto: local!dataNascita
label: "Indirizzo di residenza",
value: local!indirizzoResidenza,
saveInto: local!indirizzoResidenza
label: "Codice fiscale",
value: local!codiceFiscale,
saveInto: local!codiceFiscale
a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Invia dati",
saveInto: {
}
)
I also created a post api:
a!localVariables( local!value: cast( 'type!{urn:com:appian:types:AHUTENTE}AH_UTENTE', a!fromJson(http!request.body) ), a!writeToDataStoreEntity( dataStoreEntity: cons!AH_UTENTE_DSE_POINTER, valueToStore: local!value, onSuccess: a!httpResponse( statusCode: 200, headers: { a!httpHeader(name: "Content-Type", value: "application/json") }, body: a!toJson( fv!storedValues ) ), onError: a!httpResponse( statusCode: 500, headers: { a!httpHeader(name: "Content-Type", value: "application/json") }, body: a!toJson( { error: "There was an error writing to the data store" } ) ) ))
Now I was wondering, how do I call the API to write to the db within the interface and pass the parameters? Do I need anything else? Sorry but I'm not very practical.
Discussion posts and replies are publicly visible
Can you please wrap your code in the code window?
You will need to create an Integration object to call the API - https://docs.appian.com/suite/help/23.4/Create_an_Integration.html
When you are done creating and testing the integration successfully, then you can call that integration in your button's saveInto.
Try doing the steps I told you and if you face any errors or issues, feel free to post them here.
hi Harshit Bumb (Appyzie) ,
thanks for your your answer. I've created the integration. In the url field i need to pass the portal link? And then? How do i link the integration with the post api i've created?
In the link, you will have to pass the endpoint of the API. You can find this in your API object.
Like this?
Yes. Now a couple of things to verify and understand.
fabiopalladino Quick question - What Appian version are you using? If it is 23.4 then you can simply start a process in your button's saveInto using a!startProcess and it will start the process straight from the Portal. Just make sure you still create a service account and add it to your Portal Object's configurations. More info here - docs.appian.com/.../portals-service-accounts.html
Thanks, i'm doing this only for a little POC, so i did the basic auth method (I have to insert my appian email and password right?). But i've this error "
The external system encountered an error
Failed to connect to mptq.appian.community/.../add-new-user HTTP/1.1 500 Next Steps
"
PS:appian v. 23.4
You don't need to create an API then. You can directly start processes from a button's saveInto
I tried, the request gives me success, but it doesn't write anything in the db