how can i use both ternary operator and isnull function in SSIS? - ssis

For this table, I have two null value in suburb and postcode.
I want to change 'IsValid' column into "N" if the suburb, and postcode is "Null". otherwise the 'IsValid' is "Y"
Here's my expression:
LEN(LTRIM(RTRIM(School_Suburb))) == 0 ||
LEN(LTRIM(RTRIM(School_Postcode))) == 0 ||
ISNULL(School_Suburb) ||
ISNULL(School_Postcode) ? "N" : "Y"
and this is the error message.
So just wondering if anyone know which part I wrote it wrong? How can I change it?
this is the screenshot of derived column edit page

If you remove IsValid from the Expression and put it in the first column, currently "Derived Column 1".
The other change is that you will need to wrap the entirety of your logical ORs together with parentheses for
(LEN(LTRIM(RTRIM(School_Suburb))) == 0 || LEN(LTRIM(RTRIM(School_Postcode))) == 0 || ISNULL(School_Suburb) || ISNULL(School_Postcode)) ? "N" : "Y"
A good rule of thumb on expressions is that if it doesn't fit in the visible box, it's probably too long. Here, I'd break it out into three new columns split across two Derived Column Components.
Here I create two new columns IsSuburbInvalid and IsSchoolInvalid (although mislabled in the screenshot as Valid, not Invalid)
LEN(LTRIM(RTRIM(School_Suburb))) == 0 || ISNULL(School_Suburb)
LEN(LTRIM(RTRIM(School_Postcode))) == 0 || ISNULL(School_Postcode)
In the next Derived Column (has to be a separate component since it will use the new columns we just created), I create IsValid with a much easier to debug logic of
IsSchoolInvalid || IsSuburbInvalid ? "N" : "Y"

Related

Google Appscript IF Or statement not working

Good day everyone; I am running into an error I can't explain. The scenario is as follows, I have two input boxes that collect information. If no value is entered, I want the if statement to handle it and cause a break. The Input box also has an "x" to close the box, which returns a value of "Cancel". What I am trying to do is capture a condition where if no value is entered OR cancel is passed through, a break will occur. Right now, the problem is Google completely ignores the Or statement. I know individually, my IF logic works, but when coupled with OR it doesn't recognize the condition.
This is my current code:
var propnumber = Browser.inputBox('Enter RFI/RFQ Number', Browser.Buttons.OK);
if(propnumber != "" || propnumber != 'cancel'){} else{
SpreadsheetApp.getActiveSpreadsheet().toast('You must enter a value')
return
};
var myName = Browser.inputBox("Enter the Component Name",Browser.Buttons.OK_CANCEL);
if(myName != 'cancel')
{
I do something
}
As I mentioned in my description, my propnumber condition ignores the or and always accepts the value of cancel or blank. If I remove the or ( || ) then it works with one condition at a time.
I am sure this is something trivial any help appreciated.
What's wrong
The logic in the following part of your code
if(propnumber != "" || propnumber != 'cancel'){
// I assume some code will go here
} else{
SpreadsheetApp.getActiveSpreadsheet().toast('You must enter a value')
return
};
does not match the logic you've described here:
if no value is entered OR cancel is passed through, a break will occur.
Consider the case where propnumber is 'cancel':
propnumber != "" evaluates to true
propnumber != 'cancel' evaluates to false
Therefore the if(... || ...) condition in your code evaluates to true and the (currently empty) if block runs, rather than the else.
How to fix it
Option 1: A literal translation of the logic
if no value is entered OR cancel is passed through, a break will occur
would be
if(propnumber == "" || propnumber == 'cancel') {
SpreadsheetApp.getActiveSpreadsheet().toast('You must enter a value')
return
} else {
// Some action
}
Option 2: If you wish to swap the if and else clauses, you must negate the entire condition. So this will also work:
if(!(propnumber == "" || propnumber == 'cancel')) {
// Some action
} else {
SpreadsheetApp.getActiveSpreadsheet().toast('You must enter a value')
return
}
Note the added parentheses and single negation.
Option 3: use AND instead of OR in your existing code.
The expression !(A || B) is NOT logically equivalent to !A || !B. Instead, it is equivalent to !A && !B (see DeMorgan's Law). So this will also work:
if(propnumber != "" && propnumber != 'cancel') {
// Some action
} else {
SpreadsheetApp.getActiveSpreadsheet().toast('You must enter a value')
return
}

Google Script - if criteria met run certain functions else do nothing

I have the below script with the purpose of retrieving the value in the google sheet which will either state TRUE or FALSE. If it states false I want this script to run the two functions below (updateWIPdata and updateDebtorsdata) but if the cell value is true I don't want those functions to run at all but the functions seem to run regardless of the value in the cell so any help would be much appreciated
function updateAll() {
var updateStatus = SpreadsheetApp.getActive().getSheetByName('Updated').getRange('C2').getValue();
Logger.log(updateStatus);
if (updateStatus = 'false') {
updateWIPdata();
updateDebtorsdata();
}
}
Probably the value is a boolean.
Also, please use == or ===
if (updateStatus == false) {
Reference:
Equality operators
The fix is simple
But you also want to improve a few things in your code
The main problem is in this line:
if (updateStatus = 'false')
You are not comparing updateStatus to false, you are assigning 'false' to updateStatus. On top of that you are assigning a string, not a boolean. The line needs to be
if (false === updateStatus)
Notice three things:
false is a boolean here, it doesn't have quotation marks around it
It's on the left side of the comparison; putting litteral values on the left side is a habbit that prevents this type of error
I'm using the === comparison operator instead of the = assignment operator
Another thing you need to do is forget about var and start using const and let. If your updateStatus was a const, you would have very quickly realized the error.

how to create only one chip from the same word in Angular

I'm wondering if there is away to make my input to create only one chip from the same word instead of creating duplicate.
Right now user seem like they can create "apple" "APPLE" "apPPle" "aPpLe" so I'm figuring out a way not do that and always return with lowercase "apple" even if they type something with all Uppercase or Lowercase.
I just want to create only one chip for one word. any help or suggestion will be really appreciated.
I have tried all this but still not working
1. this.value = $event.target.value.toUpperCase()
this.ngModelChange.emit(this.value)
2. event.value=event.value.toLowerCase()
3. {{ value | lowercase }}
If I can fix this, the user might able to create "apple" "apple" multiple time but later I will prevent user from imputing the same word if "apple" is already existed/created.
Here is the project that is very similiar with mine
https://stackblitz.com/edit/angular-occkra
You need to add filtering logic to select and add methods:
if ((value || '').trim()) {
if (this.allFruits.includes(value.toLowerCase()) && !this.fruits.includes(value.toLowerCase())) {
this.fruits.push(value.trim().toLowerCase());
}
}
without include
if ((value || '').trim()) {
if (this.allFruits.find((f) => f.toLowerCase() === value.toLowerCase()) && !this.fruits.find((f) => f.toLowerCase() === value.toLowerCase())) {
this.fruits.push(value.trim().toLowerCase());
}
}

DMF and Advanced accounting structure

I have 10 dimensions in standard accounting structure and 7 dimensions defined in advanced rule.
Importing journals through DMF in excel throws error for 17 dimensions but works with 10 dimensions.
What's the right way to resolve this?
I got the solution. The issue was in generateDynamicDimension() method in DmfDimensionHelper Class.
Although It was bringing in all the dimensions values from the Segmented Entry Dimension column from Excel Sheet, it was picking only those Dimension names from the table where DimensionHierarchyType is AccountStructure and not from the Advanced Rule. I included DimensionHierarchyType of AccountRuleStructure as well. Now it's working.
while select Level from dimHierarchyLevel
order by dimHierarchyLevel.DimensionHierarchy, dimHierarchyLevel.Level
where (dimHierarchyLevel.DimensionHierarchy == dimHierarchyId
&& dimHierarchy.IsDraft == false
&& dimHierarchy.IsSystemGenerated == false
&& (dimHierarchy.StructureType == DimensionHierarchyType::AccountStructure || dimHierarchy.StructureType == DimensionHierarchyType::AccountRuleStructure)
join * from dimAttribute where
dimAttribute.RecId == dimHierarchyLevel.DimensionAttribute
exists join ledgerStructure
where ledgerStructure.DimensionHierarchy == dimHierarchy.RecId
&& ledgerStructure.Ledger == Ledger::current()
This is the additional Condtition I entered:
dimHierarchy.StructureType == DimensionHierarchyType::AccountRuleStructure

Excluding exaclty two numbers from being typed in a TextField

i want to exclude two numbers "3 and 4" from being typed in a TextField, i tried:
var theTextField:TextField = new TextField();
theTextField.type = TextFieldType.INPUT;
theTextField.border = true;
theTextField.x = 10;
theTextField.y = 10;
addChild(theTextField);
theTextField.restrict="0-9^3-4";
this successfuly excludes 3 & 4 from being typed in the textfield but it also prevent you from typing 33 or 45 for example, i only want to exclude 3 and 4. Any number with two or three digits that contains 3 or 4 should be allowed, any idea how can i do this?
So to restrict combinations 34 and 43 only?
Like Organis commented, you should validate the input via Event.CHANGE and if you already haven't let user to know about the restriction, show a warning of a somekind.
Insided the validation function you can check if the input text is "34" or "43" and then remove the second character from it to simulate the actual restriction:
theTextField.addEventListener(Event.CHANGE, validateInput);
function validateInput(e:Event):void{
if(e.target.text == "34" || e.target.text == "43"){
e.target.text = e.target.text.split("")[0];
}
}
You could also use RegExp to check the match, and .slice instead of .split inside the function:
var pattern:RegExp = /^[34|43]{2}$/;
if(pattern.test(e.target.text)){
e.target.text = e.target.text.slice(0,-1);
}
And if you're going to end up with more complex restriction patterns, with .split you can build more complex checks by checking the nth character and so on:
if(e.target.text.length == 2){
if((e.target.text.split("")[0] == "3" && e.target.text.split("")[1] == "4") ||
(e.target.text.split("")[0] == "4" && e.target.text.split("")[1] == "3")){
e.target.text = e.target.text.slice(0,-1);
}
}