Hi ,
I am using Appian contact management application tree browser code for creating org chart.but i m facing an issue when updating a contact by finding a contact using user picker and then trying to update the contact.
At that time i m getting below mentioned error
Appian code :
load( local!newContact: 'type!{urn:com:appian:recipes}CM_CustomerContact'(), local!noContacts: rule!CM_noContactDataExists(), /* Adds text-based node to the root that allows user to add a supervisor to contacts without a supervisor */ local!path: {cons!CM_ADD_ROOT_CONTACT_TEXT, if(isnull(ri!path), {}, ri!path)}, /* Used in contact finder picker */ local!foundContact: ri!targetContact, with( local!pathLength: length({local!path}), local!selectedNode: index(local!path, local!pathLength), local!actionTaken: not(isnull(ri!goTo)), local!newContactSelected: not(rule!CM_isCustomerContact(local!selectedNode)), local!workStarted: if( local!newContactSelected, /* Checks to see if the user has added any values. The user does not set the supervisor, so our check needs to ignore the supervisorId. */ local!newContact <> 'type!{urn:com:appian:recipes}CM_CustomerContact'(supervisorId: local!newContact.supervisorId), and( local!actionTaken, ri!targetContact <> cast('type!{urn:com:appian:recipes}CM_CustomerContact', local!selectedNode) ) ), a!formLayout_17r1( firstColumnContents: { a!sectionLayout_17r1( label: "Reporting Structure", isCollapsible: true, firstColumnContents: { rule!CM_contactFinder( path: local!path, targetContact: ri!targetContact, foundContact: local!foundContact, root: cons!CM_ADD_ROOT_CONTACT_TEXT ), a!hierarchyBrowserFieldTree( pathValue: local!path, /* Numbers outline what happens when a user clicks on a "Add New" node */ pathSaveInto: if( /* 1. If the user has started editing a new contact or updating an existing contact, we block navigation by setting the pathSaveInto to null */ or(local!workStarted, local!actionTaken), null, /* 2. If work is NOT in progress, always save the path. We need to save the path for the component to respond to a user's click. */ { local!path, /* 3. The add new root is dropped from local!path and the result is saved to ri!path. ri!path is a CustomerContact list that cannot hold the text value of a new root contact node */ a!save(ri!path, ldrop(local!path, 1)), with( local!selectedNode: rule!CM_getSelectedValue(local!path), /* If a contact is clicked save the selected node as to the "targetContact" and "foundContact" Otherwise, a new contact node is clicked. Therefore: Set the new contacts supervisorId to the value above it in the path */ if( rule!CM_isCustomerContact(value: local!selectedNode), a!save( { ri!targetContact, local!foundContact, /* save!value is local!selectedNode. Save the image of the selected node */ a!save(ri!newOrUpdatedImage, save!value.imageId) }, local!selectedNode ), /* 4. `local!newContact.supervisorId` is updated with what will be the new node'ssupervisor. We update the `local!newContact.supervisorId` so that the new contact form below the hierarchy browser tree shows the correct supervisor */ { a!save( local!newContact.supervisorId, rule!CM_multiIndex(local!path, {length({local!path}) - 1, "id"}, null) ), /* 5. Drop add new node from the path. ri!path is a CustomerConact list and cannot hold the text value of a new contact node. */ a!save(ri!path, rdrop(local!path, 1)), a!save({ri!targetContact, local!foundContact}, null), a!save(ri!newOrUpdatedImage, null) } ) ) } ), nextLevelValues: { if( rule!CM_isCustomerContact(fv!nodeValue), rule!CM_getSubordinatesFromCustomerContact(contact: fv!nodeValue), rule!CM_getContactsWithNoSupervisor() ), /* Add text-based node to allow users to add a contact at this level */ cons!CM_ADD_CONTACT_TEXT }, nodeConfigs: if( rule!CM_isCustomerContact(fv!nodeValue), rule!CM_customerContactNodeConfigs(contact: fv!nodeValue), rule!CM_textBasedContactBrowserNode( text: cons!CM_ADD_CONTACT_TEXT, icon: a!iconIndicator("ADD"), isDrillable: and(fv!nodeValue = cons!CM_ADD_ROOT_CONTACT_TEXT, not(local!noContacts)) ) ) ), if( /* Hide buttons if a new contact is selected or an action has been taken */ or( local!newContactSelected, local!workStarted, local!actionTaken ), {}, a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Update Contact", value: cons!CM_CUSTOMER_CONTACT_ACTIONS[1], saveInto: ri!goTo ), a!buttonWidgetSubmit( label: "Delete Contact", value: cons!CM_CUSTOMER_CONTACT_ACTIONS[2], saveInto: { /* 1. ri!goTo is updated to take the process flow through the correct path */ ri!goTo, /* 2. The root node is removed from the path and the deleted value is removed, allowing us to bring the user back to the supervisor of the deleted contact. */ a!save(ri!newOrUpdatedImage, null), /* 3. The root and target contact are removed from the path */ a!save(ri!path, rdrop(ldrop(local!path, 1), 1)) } ) } ) ) } ), if( local!newContactSelected, { rule!CM_contactInformationSection( contact: local!newContact, label: cons!CM_ADD_CONTACT_TEXT, newOrUpdatedImage: ri!newOrUpdatedImage, path: ri!path ), a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: "Create New Contact", style: "PRIMARY", value: local!newContact, saveInto: { ri!targetContact, a!save(ri!goTo, cons!CM_CUSTOMER_CONTACT_ACTIONS[1]), a!save(ri!rootContactAdded, local!selectedNode = cons!CM_ADD_ROOT_CONTACT_TEXT) } ), a!buttonWidget( label: "Cancel New Contact", disabled: not(local!workStarted), saveInto: { a!save(local!newContact, 'type!{urn:com:appian:recipes}CM_CustomerContact'()), /* Remove the "Add New" from the path when they hit cancel if it's not the root */ if(local!pathLength > 1, a!save(local!path, rdrop(local!path, 1)), null), a!save(ri!path, rdrop({ri!path}, 1)), if( rule!CM_isCustomerContact(rule!CM_getSelectedValue(local!path)), a!save(ri!targetContact, rule!CM_getSelectedValue(local!path)), null ), a!save( ri!newOrUpdatedImage, index(ri!targetContact, "imageId", null) ) } ) } ) }, { rule!CM_contactInformationSection( contact: ri!targetContact, isDisabled: not(local!actionTaken), label: "Update " & rule!CM_displayContactFullName(ri!targetContact), newOrUpdatedImage: ri!newOrUpdatedImage, path: ri!path ), if( not(local!actionTaken), {}, a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: "Confirm Update", style: "PRIMARY" ), a!buttonWidget( label: "Cancel Update", value: null, saveInto: { ri!goTo, a!save(ri!newOrUpdatedImage, ri!targetContact.imageId), a!save(ri!targetContact, local!selectedNode) } ) } ) ) } ) }, buttons: a!buttonLayout( secondaryButtons: { a!buttonWidgetSubmit( label: "Close", skipValidation: true, confirmMessage: if( local!workStarted, "Are you sure you want to continue? All contact update or new contact information will be lost.", "" ), value: cons!CM_CUSTOMER_CONTACT_ACTIONS[3], saveInto: ri!goTo ) } ) ) ))
Kindly request anyone to provide solution for this issue.
Thank you.
Discussion posts and replies are publicly visible