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
12 replies
Subscribers
7 subscribers
Views
4314 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
We have an issue with a variable overwriting another variable within a sail form
ashleyb
over 9 years ago
We have an issue with a variable overwriting another variable within a sail form. These variables initially have the same value and then one is modified by the user while the other remains a "read only" version. The issue we are having is when the user edit's the editable variable, the values are being overwritten in the "read only" variabe - before anything is saved to the databse (the database is the original source for both).
load(
/*Retrieving fresh exception data from the SQL database before populating to the user (Added with Release 6)*/
ri!eadOnly_exceptionDetails_cdt : rule!CAC_getExceptionByIDAndNotStatus(ri!exceptionDetails_cdt.crsExceptionID, "Cleared"),
ri!exceptionDetails_cdt : rule!CAC_getExceptionByIDAndNotStatus(ri!exceptionDetails_cdt.crsExceptionID, "Cleared"),
local!noDocAttached_bool: if(
getdocumentsfromfolder(
rule!findExactFolderNameMatch(
ri!exceptionDetails_cdt.crsExceptionID
),
...
OriginalPostID-168667
OriginalPostID-168667
Discussion posts and replies are publicly visible
Parents
0
sikhivahans
over 9 years ago
@ashleyb Hi, may I know how you concluded this?
The behavior which is being observed by you could be only seen in following cases:
1. If you have sent the variable to other expressions via rule inputs and updating the variable in other expressions, then yes, there could be a chance. It would be good to elaborate what has been written in the below rule. This is the only area which we could check if the readOnly_exceptionDetails_cdt is being modified because the other code snippet isn't updating the readOnly_exceptionDetails_cdt.
Example:
rule!CAC_Exception_Details_Elements_CRSRelease3(
ri!readOnly_exceptionDetails_cdt, readOnly_exceptionDetails_cdt'
ri!exceptionDetails_cdt,
ri!returnCodeXML_Txt
)
2. Further your code seems to have a rule input and local variable with same name. There is no problem in doing so, but you need to remember that you are no more working on a rule input but you are working on a local variable. It's not a good idea to do this, if possible please try to use different names for local variables as well as rule input variables. I would like to suggest to resolve this, as this may also lead to some confusion while debugging the code and leads to less readability issues.
Example:
ri!exceptionDetails_cdt : rule!CAC_getExceptionByIDAndNotStatus(ri!exceptionDetails_cdt.crsExceptionID, "Cleared"),
/*
\tri!exceptionDetails_cdt doesn't act as rule input from hereafter. When you say ri!exceptionDetails_cdt or exceptionDetails_cdt, it is a local variable but doesn't refer a rule input any more. Same applies to ri!readOnly_exceptionDetails_cdt as well.
*/
3.Also I would like to suggest to check a possibility of surfacing a value from exceptionDetails_cdt where you actually needed to surface readOnly_exceptionDetails_cdt?
Further, is the code snippet a complete one? As said by other users, I could see some syntactical errors. And just to give you one more hint, until and unless you push the values into readOnly_exceptionDetails_cdt by making use of 'saveInto' of SAIL interface, the variable holds only that data which is queried initially in load(i.e. by making use of rule!CAC_getExceptionByIDAndNotStatus(ri!exceptionDetails_cdt.crsExceptionID, "Cleared"))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
sikhivahans
over 9 years ago
@ashleyb Hi, may I know how you concluded this?
The behavior which is being observed by you could be only seen in following cases:
1. If you have sent the variable to other expressions via rule inputs and updating the variable in other expressions, then yes, there could be a chance. It would be good to elaborate what has been written in the below rule. This is the only area which we could check if the readOnly_exceptionDetails_cdt is being modified because the other code snippet isn't updating the readOnly_exceptionDetails_cdt.
Example:
rule!CAC_Exception_Details_Elements_CRSRelease3(
ri!readOnly_exceptionDetails_cdt, readOnly_exceptionDetails_cdt'
ri!exceptionDetails_cdt,
ri!returnCodeXML_Txt
)
2. Further your code seems to have a rule input and local variable with same name. There is no problem in doing so, but you need to remember that you are no more working on a rule input but you are working on a local variable. It's not a good idea to do this, if possible please try to use different names for local variables as well as rule input variables. I would like to suggest to resolve this, as this may also lead to some confusion while debugging the code and leads to less readability issues.
Example:
ri!exceptionDetails_cdt : rule!CAC_getExceptionByIDAndNotStatus(ri!exceptionDetails_cdt.crsExceptionID, "Cleared"),
/*
\tri!exceptionDetails_cdt doesn't act as rule input from hereafter. When you say ri!exceptionDetails_cdt or exceptionDetails_cdt, it is a local variable but doesn't refer a rule input any more. Same applies to ri!readOnly_exceptionDetails_cdt as well.
*/
3.Also I would like to suggest to check a possibility of surfacing a value from exceptionDetails_cdt where you actually needed to surface readOnly_exceptionDetails_cdt?
Further, is the code snippet a complete one? As said by other users, I could see some syntactical errors. And just to give you one more hint, until and unless you push the values into readOnly_exceptionDetails_cdt by making use of 'saveInto' of SAIL interface, the variable holds only that data which is queried initially in load(i.e. by making use of rule!CAC_getExceptionByIDAndNotStatus(ri!exceptionDetails_cdt.crsExceptionID, "Cleared"))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data