Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
19 replies
Subscribers
7 subscribers
Views
6248 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Adding a new row in a grid(interface)
sowjanyav430
over 7 years ago
Hi
I want to auto increment a user defined id in a grid when a new row is added.
I was able to increment the id but facing an issue...
Test scenario:
Add 2 new rows,delete the 1st row,
again add a new row.
In this scenario am getting the repeated id.
This is because i have used grid row index for id increment,
Please refer the attached screenshots for more details.
Can anybody suggest me how to handle this scenario.
Thanks in advance.
OriginalPostID-239262
Discussion posts and replies are publicly visible
0
Vinay Kumar Rai
over 7 years ago
Hi
Best way you can use "Index" variable, guess you pass a Index variable in you sub-rule
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sowjanyav430
over 7 years ago
Yes vinay,
i used index variable....
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Dastagiri Dudekula
over 7 years ago
Try Using separate variable for retaining id. This id must be synchronizing with database count which helps in maintaining uniqueness in id generation. Using this id you can have flexibility in increment and decrement
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinay Kumar Rai
over 7 years ago
Can you please share your code.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shashank
over 7 years ago
@Sowjanya , Hi , it would be helpful , if you can attach the code snippet
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sowjanyav430
over 7 years ago
addRowlink: a!dynamicLink(
label: "Add New Employee",
value: 'type!{urn:com:appian:types}SVG_IAL1_Employee'(
employeeId: rule!SVG_IAL17_EmpAutoGenForGrid(
if(
rule!SVG_IAL_CheckForNull(
ri!employeeDetails
),
1,
count(
ri!employeeDetails
) + 1
)
)
),
and my rule is :
if(len(ri!employeeId)=0,
concat("INC-",stripwith(ri!employeeId,"INC-")+1)
,concat("INC-",right(year(today()),2),0,0,0,ri!employeeId)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinay Kumar Rai
over 7 years ago
Hi
Best approach to show the Employee-Id dynamically, don't add in the CDT in Add Link
a!textField(
value:
if(len(ri!CDT[ri!Index].employeeId)=0,
concat("INC-",stripwith(ri!CDT[ri!Index].employeeId,"INC-")+ ri!Index)
,concat("INC-",right(year(today()),2),0,0,0,ri!CDT[ri!Index].employeeId)
)
)
On the save of first name you can also save the Employee-Id to
a!save(
ri!CDT[ri!Index].employeeId,
if(len(ri!employeeId)=0,
concat("INC-",stripwith(ri!CDT[ri!Index].employeeId,"INC-")+ ri!Index)
,concat("INC-",right(year(today()),2),0,0,0,ri!CDT[ri!Index].employeeId)
)
)
Hope this help
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinay Kumar Rai
over 7 years ago
Some correctness don't save Employee-Id on First Name,
instead save Employee Ids on Submit button
Uses a Rule called : TEST_Format_EmployeeId
On Submit button save :
a!save(
ri!CDT.employeeId,
apply(
rule!TEST_Format_EmployeeId(ri!CDT.employeeId,_),
1+enumerate(count(ri!CDT))
)
)
Rule : TEST_Format_EmployeeId
paramaters : EmployeeIds text array
Index number
=with(
if(
len(ri!EmployeeIds[ri!Index])=0,
concat("INC-",stripwith(ri!EmployeeIds[ri!Index],"INC-")+ri!Index),
concat("INC-",right(year(today()),2),0,0,0,ri!EmployeeIds)
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sowjanyav430
over 7 years ago
@Vinay..
I want to show employee Id to the user upon clicking on the link,but not the button(as hidden)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
venkateshs329
over 7 years ago
@ sowjanya
Please try attached code[Run this code] , it may helpful to you.
Code.txt
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>