Nested If Statements for Multiple Conditionals - livecycle

I need something similar to the following script (this would ideally go into a LiveCycle "calculate" event field):
if(Subform.TextField1.rawValue !== null && Subform.TextField2.rawValue !== null && Subform.TextField3.rawValue !== null &&
Subform.TextField4.rawValue !== null &&
((TableSubform.Table.Row1.TextField5.rawValue == null && (TableSubform.Table.Row1.TextField6.rawValue == null && (TableSubform.Table.Row1.TextField7.rawValue == null) ||
(TableSubform.Table.Row1.TextField5.rawValue !== null && (TableSubform.Table.Row1.TextField6.rawValue == "Yes" && (TableSubform.Table.Row1.TextField7.rawValue == null) ||
(TableSubform.Table.Row1.TextField5.rawValue !== null && (TableSubform.Table.Row1.TextField6.rawValue == "No" && (TableSubform.Table.Row1.TextField7.rawValue !== null)) &&
((TableSubform.Table.Row2.TextField5.rawValue == null && (TableSubform.Table.Row2.TextField6.rawValue == null && (TableSubform.Table.Row2.TextField7.rawValue == null) ||
(TableSubform.Table.Row2.TextField5.rawValue !== null && (TableSubform.Table.Row2.TextField6.rawValue == "Yes" && (TableSubform.Table.Row2.TextField7.rawValue == null) ||
(TableSubform.Table.Row2.TextField5.rawValue !== null && (TableSubform.Table.Row2.TextField6.rawValue == "No" && (TableSubform.Table.Row2.TextField7.rawValue !== null))
} else {
this.rawValue="Not complete"
Basically, I have a form with four fields on top that need to be completed. Then, I have a three column table (first row being the header) with two rows of fillable text fields with the following rules in order for the form to be deemed complete:
If TextField5 is blank, then TextField6 and Textfield7 do not need to be filled in
If TextField5 is not blank, then TextField6 needs to be filled in with "Yes" or "No"
If TextField6 is "Yes," then TextField7 does not need to be filled in
If Textfield6 is "No," then TextField7 does need to be filled in
Please let me know where my script went wrong! Thanks!

First, from what I see this is not nested IF statement, it's a whole one command of and/or. Of course such code is not preferable, so first try to divide your conditions into something like this:
if(Subform.TextField1.rawValue !== null && Subform.TextField2.rawValue !== null)
if(another condition)
if(another condition).....etc
See, doing nested IF statements means for each command, there is other options to do.
For the conditions, if this language is JAVA then you need to use ActionListener
In order to write your commands in, it means when for example your TextField6 is "no", then using ActionListener you will write the command code that TextField7 need to be filled in.

If TextField5 is blank, then TextField6 and Textfield7 do not need to be
filled in. If TextField5 is not blank, then TextField6 needs to be filled in with "Yes" or "No".If TextField6 is "Yes," then TextField7 does not need to be filled in.If Textfield6 is "No," then TextField7 does need to be filled in.
Based on your description I would make a set of statements that look like this.
if (TextField5.isNull) this.rawValue = "Complete";
else {
if (TextField6.rawValue == "Yes") this.rawValue = "Complete";
else {
if (!TextField7.isNull) this.rawValue = "Complete";
else this.rawValue = "Not Complete";
But really, there's only one condition where you can have an incomplete form (it seems): TextField5 is filled, TextField6 is "No", and TextField7 is empty. So, you can condense that down into one statement and mark anything else complete.
if (!TextField5.isNull && TextField6.rawValue == "No" && TextField7.isNull) this.rawValue = "Not Complete";
else this.rawValue = "Complete";


React form validation for multiple field

I am new to React. I have a very simple form which contains employer address details. I would like to validate if any of the fields got value, then check if length is <=10 and if not exists the it is fine. There are no mandatory validation and only length valiation if exists.
currently doing like below:
const isValid=
employer.address == null ||
(employer.address != null &&
(employer.address.building?.length <= 2) &&
employer.address.street?.length <= 2 &&
employer.address.county?.length <= 2 && <= 2 &&
employer.address.postcode?.length <= 2);
Is there a better way to test to check validation if it contains value and ignore if not.
it is neither bad nor the best way
with current code you can do a bit clean Up to make it look nicer
you can assign a const to employer.address so no need to repeat it
const emp = employer.address
const isValid=
(emp.building?) &&
emp.county?&& &&
in the example above validation works if data is '' but if it has anything inside it ('s') validation would not be called
i think it should work same way
also there are some packages that provide you validation
redux form

Apex Trigger to update the value of Related to company field ( if it is null only) on the task object based on the related to contact

I need to write a trigger to pre-fill the value of "Related to: company" field ( if it is null only) on the task object based on the "related to: contact" field value before submitting the record. Please help me how can I achieve this.
Thanks, Shweta
trigger TaskTrigger on Task (after update) {
for(Task newTask : Trigger.New){
// Task.WhoId != null ----Checks Contact is null or not
// ((string)Task.WhoId).startsWith('003') ----Checks Task is related to Contact
// Task.WhatId == null ----Checks the related to field is null or not
if(Task.WhoId != null && ((string)Task.WhoId).startsWith('003') && Task.WhatId == null ){
// Add your code as per your needs.

ng-if -> multiple 'OR' condition is not working

ng-if="self_employment.business_type != 'Trust' || self_employment.business_type !== 'Partnership'"
Use != instead of !== :
ng-if="self_employment.business_type != 'Trust' || self_employment.business_type != 'Partnership'"
When You face this kind of problems, First check the object is defined or not. print the {{self_employment.business_type}} in the Html/console. If it is coming "trust/partnership" then it is in lowercase. if it is lowercase it may cause to fail the condition.
"trust" === "Trust" // false
"trust" == "Trust" // false
"trust" == "trust" // true

Swift remove item in array

I have a Problem with SwityJson and removing an Element of an Array
For further Datahandling i must remove some Elements.
here my Code
self.jsonObj = JSON(value)
for i in 0 ..< self.jsonObj["customer"].count {
if self.jsonObj["customer"][i]["Group_A"].string == "Mr Abcde"
|| self.jsonObj["customer"][i]["Group_A"].string == "Mr Bcde"
|| self.jsonObj["custome"][i]["Group_B"].string == "Mr Abcde"
|| self.jsonObj["customer"][i]["Group_B"].string == "Mr Bcde"
Now the Problem: If running the Code not all found Element are removed.
I think that looping through all Elements is too fast. There is noch Time for the removing Task?!
How can I handle it. Looping...found something...stop looping...remove Item...start looping..
By making the If-Statement for three Times all is fine an all found Elements are removed, but hey, this is not what i want.
Or is it possible to filter the Array an then say
filterdData = jsonObj
for i in 0 ..< self.jsonObj["customer"].count {
let groupA = self.jsonObj["customer"][i]["Group_A"].string
let groupB = self.jsonObj["customer"][i]["Group_B"].string
if groupA == "Mr Abcde" || groupA == "Mr Bcde" || groupB == "Mr Abcde" || groupB == "Mr Bcde"{
Not only does this have less calls to the JSON object(potentially saving speed) but it also uses rawArray instead of arrayObject which writes directly the array instead of going through the arrayObject to the rawArray.
The problem is that you're changing the count that terminates the loop from within the loop. You need to not do that, perhaps using filter or a related approach instead
I would recommend normalizing the data before modifying it. But failing that you could try this:
let filteredJson = self.jsonObj["customer"].filter { elem in
!(["Mr Abcde", "Mr Bcde"].contains(elem.["Group_A"].string) ||
["Mr Abcde", "Mr Bcde"].contains(elem.["Group_B"].string))
and then use the filteredJson constant.

Filtering a Collection using Linq based on Combo boxes Selections

i use the following code to filter a collection based on the user options which are captured via combo boxes and sent to view model or controller to implement a cascade filtering:
IEnumerable<SubsystemDTO> _ssDTOs = _subsystemService
.Where(s => s.MS != null
&& s.MS.Equals(_subsystemRptPanelViewModel.SelectedMS)
&& _subsystemRptPanelViewModel.SelectedMS != "All")
.Where(s => s.Flag != null
&& s.Flag.Equals(_subsystemRptPanelViewModel.SelectedFlag)
&& _subsystemRptPanelViewModel.SelectedFlag != "All")
.Where(s => s.Scope != null
&& s.Scope.Equals(_subsystemRptPanelViewModel.SelectedScope)
&& _subsystemRptPanelViewModel.SelectedScope != "All");
I have 3 combo boxes which collect the user options and they are applied to the collection in cascading manner as shown. The the data are fetched from a database which contain values equal to those passed by the combo boxes my questions are:
1.If the user choose not to filter by Flag for example, so he selects option All in that combo box how to apply that to the above linq query
2.Generally if the user wants to filter by a value in the combo box that doesn't has peer in the database how to do that (like All option in 1 or the invert of an option)
Note: i tried to add the statement [_subsystemRptPanelViewModel.SelectedMS != "All"] to exclude implementing the filter if all selection is selected by the user but when selecting All option in one combo box, the result is an empty query result.
If the user choose not to filter by Flag for example, so he selects option All in that combo box how to apply that to the above linq query.
You want to return the values where either the value matches what the user selected OR the user has selected 'All' values: this first example follows the pattern of your query above, and only returns values where the SubsystemDTO values (MS, Flag, Scope) are not null.
.Where(s => s.MS != null
&& (_subsystemRptPanelViewModel.SelectedMS == "All"
|| s.MS.Equals(_subsystemRptPanelViewModel.SelectedMS)))
// etc
If you wanted to return all values regardless of whether the SubsystemDTO properties are populated, you would move the ALL check to the top:
.Where(s => _subsystemRptPanelViewModel.SelectedMS == "All"
|| (s.MS != null && s.MS.Equals(_subsystemRptPanelViewModel.SelectedMS)))
// etc
To mix "Not' into this query you have to compare the result of the Equals comparison with whether or not the value 'Is' or "Is Not' the one specified by the user
If you had a view model property called IsMatch which was true when the user wanted to match the selected value, and false when the values which do not match the selected value:
.Where(s => _subsystemRptPanelViewModel.SelectedMS == "All"
|| (s.MS != null && s.MS.Equals(_subsystemRptPanelViewModel.SelectedMS)
// etc