Suppress blank lines in Word when using IF Field codes - ms-word

I am using the following to conditionally output text in an MS Word document:
{ IF { DOCPROPERTY manual_version } = 1 "Version 1" "" \* MERGEFORMAT }
{ IF { DOCPROPERTY manual_version } = 2 "Version 2" "" \* MERGEFORMAT }
{ IF { DOCPROPERTY manual_version } = 3 "Version 3" "" \* MERGEFORMAT }
If manual_version is set to 3, then the text "Version 3". The previous IF field codes aren't supposed to output anything but they output a blank line. How do I change that?

Your entire field code construction could be reduced to:
{DOCPROPERTY manual_version \# "'Version '0;;"}

Related

Ag-grid set column text filter to range of letters

The goal is to set a column's text filter to be a range of letters that values start with. For example in a customer name column setting the filter to be "starts with" and a range of a-m. The user will enter the two letters that define the start and end of the range (eg. "a" and "m").
Ag-grid's filter docs state that "in range" filtering is only supported for date and number data types. Looking at ag-grid's multi-filter example, multiple filters are combined with an OR condition in the filter model:
{
athlete: {
filterType: "multi",
filterModels: [
{
filterType: "text",
operator: "OR",
condition1: {
filterType: "text",
type: "startsWith",
filter: "a"
},
condition2: {
filterType: "text",
type: "startsWith",
filter: "b"
}
},
null
]
}
}
It looks like the solution is to programmatically find all letters in the range specified by the user, then include a condition for each letter in the "filterModels" array. Is there a more efficient way to do this?
A custom filter was the best solution for this scenario.
I was looking to support an optional range of letters, along with optional additional text in the filter field. Using a regular expression that matched this pattern inside the doesFilterPass method is working as expected.
Example using Vue and lodash:
doesFilterPass(params) {
// Regex matches "[A-M]", "[n-z]", "[E-p] additionaltext", etc
const nameFilterRegex = /^(?<nameStartRange>\[[a-z]{1}-[a-z]{1}\])?(?:\s+)?(?<additionalText>[a-z]+)?(?:\s+)?$/i;
const regexResult = nameFilterRegex.exec(params.data.name);
if (!isNil(regexResult)) {
const nameRange = regexResult.groups.nameStartRange;
const additionalText = regexResult.groups.additionalText;
if (!isEmpty(nameRange)) {
try {
const lastNameRegex = new RegExp(nameRange, "gi");
const matchedChar = params.data.name[0].match(lastNameRegex);
if (isEmpty(matchedChar)) {
return false;
}
} catch {
return false;
}
}
if (!isEmpty(additionalText)) {
if (!params.data.filterValue.includes(additionalText)) {
return false;
}
}
}
return true;
};

How to access Delete Row function in a Multivalued row for a Eureka form

I would like to access the delete row function in the eureka form but I couldn't find how to do it. The reason is that I have an i variable that keeps track of how many rows I have and because of that my form breaks when a row is deleted.
This is how my implementation currently looks in my code:
+++ MultivaluedSection(multivaluedOptions: [.Reorder, .Insert, .Delete], header: "Exercises", footer: "List of Exercises for workout"){
$0.addButtonProvider = {section in
return ButtonRow(){
$0.title = "Add Another Exercise"
self.i+=1
}
}
$0.multivaluedRowToInsertAt = { index in
return TextRow() {
$0.title = "Exercise \(self.i) Name"
$0.tag = "Exercise \(self.i) Name"
self.i+=1
}
}
$0 <<< TextRow(){ //change this to SuggestionRow later
$0.title = "Exercise \(self.i) Name"
$0.tag = "Exercise \(self.i) Name"
$0.add(ruleSet: strictRules)
}
}
What I'm looking for is something like:
$0.multivaluedRowToDeleteAt = { index in
self.i-=1
}
Does something like this exist? If not, is there any other way to get the number of rows for this multivalued section at submission time?

How to mail merge multiple records to one document

I need to mail merge Access data from multiple records into 1 document. The document has standard text (form letter in the code below) at the top, followed by fields common to all the records (vendor), followed by multiple rows unique to each record (BC, Account, subaccount, amount), finally followed by more common data (payee) and text (more stuff).
Instead of putting all the record specific data together in the middle of the document, I get the first block of common data, then data from 1 record, the the rest of the common data, then the data from the 2nd record.
My setup in Word is
{ if{ mergeseq } ="1" { set var1 "" } { set var1{ mergefield key } }}
{ if { var1 } <>{ var2 } "{ if { mergeseq } <>"1" "}
Form letter
{ MERGEFIELD "Vendor_" }
" ""}
{ MERGEFIELD "BC" } { MERGEFIELD "Account" } { MERGEFIELD "SubAccount" }
{ MERGEFIELD "Amount" }
{ if { var1 } <>{ var2 } "{ if { mergeseq } <>"1" "}
more stuff
{ MERGEFIELD payee}
" ""}
{ set var2 { mergefield key }}
I'm using Office 2010.

Detect empty pick() from hash in KRL

I have a bunch of data in a hash and I am picking from it. Sometimes there will be data there to pick and sometimes there won't. What is the best way to know when there was something found by the pick operator and when there wasn't so I can react to that in my code?
The pick operator will take a second optional parameter that will make it so that it always returns the results in an array. This means that if something is picked, the length of the array will be greater than 0, otherwise it will be 0. You can then use that to do what you are wanting to do.
Example code/app taken from http://kynetxappaday.wordpress.com/2011/01/04/day-30-detecting-empty-pick/
ruleset a60x526 {
meta {
name "hash-pick-detect"
description <<
hash-pick-detect
>>
author "Mike Grace"
logging on
}
global {
dataHash = {
"one": {
"name": "Mike"
}, // number
"two": {
"random": 8
}, // number
"three": {
"name": "Alex"
} // number
}; // dataHash
} // global
rule detect_the_pick {
select when pageview ".*"
foreach dataHash setting (key, value)
pre {
userName = value.pick("$.name", true);
length = userName.length();
}
if (length > 0) then {
notify("Key: #{key}","Name: #{userName}<br/>Length: #{length}") with sticky = true;
}
notfired {
raise explicit event empty_pick
with pickedKey = key;
}
}
rule empty_pick_found {
select when explicit empty_pick
pre {
pickedKey = event:param("pickedKey");
results =<<
Key: #{pickedKey}<br/>
doesn't have a name associated with it to pick from
>>; //' fixing syntax highlighting
}
{
notify("An empty pick was detected",results) with sticky = true;
}
}
}

How to read dictionary with child

Help me in reading this dictionary: (its an NSDictionary generated from XMLData)
Menus = {
Table1 = {
Phone = {
text = "\n (404) 371-1466";
};
text = "\n ";
};
text = "\n";
};
}
This should get you the phone number, for example:
NSString *phoneNum = [[[[dict objectForKey:#"Menus"] objectForKey:#"Table1"]
objectForKey:#"Phone"] objectForKey:#"text"];
You have one item in the dictionary - "Menus".
That single item is a dictionary, with two items - "Table 1" and "text". "Table 1" is a dictionary, "text" is an NSString.
Inside "Table 1", you have two items - "Phone" and "text". At this point, I think you can see the pattern...