Setting default value for OptionSet in CRM 2011 Dialog - dialog

I have a requirement to populate the default value for an OptionSet in a Prompt-Response based on a value pulled in from a query within the Dialog. However, the default value field is disabled for both types of OptionSet.
Can anyone confirm if this is the correct behaviour as I can't think of any reason why you wouldn't be able to assign a default to an OptionSet at runtime?
This will mean duplicating the entire Page as I can't even add a Condition statement to conditionally use different Prompt-Responses unless anyone can offer a better solution?

When you do query that means you are getting a set of values, even if it's a single one.
So, yo can pupulate an Option Set from Query but not set a default value.
Anyway, default value field is not for OptionSets it's for text, numeric and DateTime responses.
I am not quite understand your last question.
Could you give more detail.

Long time since the question got asked.
The simplest answer is that you can´t set a default value to the option set.
However another sollution instead of duplicating the page, and that may be useful in a case like this, is a workaround with two queries.
Declare a variable of the type you want to be dynamic in the Query for the Option set.
Set the variable to a value that would give you the default Option set value you´re looking for.
Query for the data that you want to use with the dynamic type you want to use.
Check number of records the query returns.
If number of records is more than 0 you set the value of the variable to the dynamic vaule used in the query
Query for the same data again(!), this time with the variable instead of the previously used dynamic value, and use this one for the Option Set.
The result is: If you get hits from your query, the hits will be shown in the option set. If you don't get hits the "default" value will be shown.
Also don't think there is any reason why you wouldn't be able to set a default value for the Option set. Especially since the page locks up if the query used for the option set returns no hits.
Cheers.
/Henrik

Further to this I have come across a situation today where I have used some fetchxml to query data in a dialog and are now wanting to store that value within a variable but appears I cant and can only use this to show fields within an option set.
I appreciate the xml is returning a record and not a field but there must be away I can return first or default and store the returned value in a variable.

Related

LotusScript - Why do we use array index to access value of text field

I am working on some LotusScript code and came across this syntax to access a text field value: textField(0). I checked this field's properties in the design and it has the type of Text and doesn't allow multiple values. But why do we use the index to access this field value? I need to describe what the code is doing so it makes a difference between "get the value of textField then do something" vs. "get the first element of textField then do something".
The LotusScript expression document.textField is a shorthand form of document.GetItemValue("textField"). As explained in Designer Help, this expression always returns an array of strings for text or text list fields. That's why one has to use document.textField(0), or document.GetItemValue("textField")(0) for that matter, to access the first (and possibly only) element in the returned array.
An important thing to remember is that just because the field properties say that multiple values aren't allowed today, they might have been allowed in the past. Nothing gets "fixed up" in old documents if you change the properties in Domino Designer. Your code always has to consider that possibility.
And for that matter, even when the field properties do say that multiple values aren't allowed, those properties only apply when a user is editing the document using the defined form. An agent or code using any of the Notes APIs can always store multiple values in any text field.
That's why you always access item values through an array. It's not just a matter of "that's how the API works". It's a matter of how the underlying storage works.
And remember: Notes is schemaless. You have to always assume the following:
The item that corresponds to the field might not exist.
The item might be empty even if there's a validation formula that requires it to be filled in.
The item that corresponds to a text field might not actually be a text item.
The item can contain a list even if the multi-values property is not checked.

How do I use Office.JS to add invisible information to a cell in Excel?

I need to add some information to an Excel cell or the same information to several selected Excel cells and that information should not be visible. How is this possible? I know I could add something to the properties of the whole worksheet, using the addresses (e.g. "Sheet1!A1") of the cells, but then when the table changes, the information is no more correct. I also thought I could use addFromSelectionAsync, but did not manage to use it, I think addFromSelectionAsync is not the right tool. I have seen that other AddIns are producing something like the follwoing (in different files in the saved Excel document): [UPDATE: this is not the way to go, see my second comment below]
<x15:webExtensions xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main">
<x15:webExtension appRef="{12345678-...}">
<xm:f>Sheet1!$A$1</xm:f>
</x15:webExtension>
<x15:webExtension appRef="{ABCABCAB-...}">
<xm:f>Sheet1!$A$2</xm:f>
</x15:webExtension
</x15:webExtensions>
<we:bindings>
<we:binding id="BINDING-ID-1" type="text" appref="{12345678-...}"/>
<we:binding id="BINDING-ID-2" type="text" appref="{ABCABCAB-...}"/>
</we:bindings>
and then use <we:properties> (I think) to know which binding-IDs are used. Is this the way to go, will the values in <xm:f> automatically be updated, and how do I do this in code?
Thanks in advance.
The first part was already resolved see my old comments above:
addFromPromptAsync, using the information I want to save as the ID, adds the <x15:webExtension> and the according <we:binding>.
I am now using a UUID as the value in addFromPromptAsync, and setting the actual value via Office.context.document.settings.set with key = the UUID and value = the actual value.
It was then my question:
given a cell (i.e. the accordings range) I cannot get the IDs of the according bindings
For this second part of the problem, I added event handlers via binding.addHandlerAsync for the relevant Binding-IDs. Those event handler can read the binding ID from the event data.
So my problem is resolved, since I only need the Binding ID when the according cell is selected.
There is still the problem that I need to unset the binding ID that I save in a variable when another cell without that data is selected, I am using a timestamp for this, >200ms after the last binding selection event, selecting another cell deletes the info. Cf. my question Can I set an order for the Event Handlers in Office.JS? for that last point.

Kentico - Change Pagetype Field Name without blanking out current values

I have a custom page type for Staff and there's a field called Function. I have a WHERE condition in a repeater like this: Function LIKE '%insurance%' and got an error Incorrect syntax near the keyword 'Function'
From the error I guess Function is a reserved keyword, so I changed the field name to BusinessFunction. However right after changing the field name, I noticed all the values for that field become blank. If I changed it back, the values are back to normal. The question: is there a way to change the field name while keeping the values that are already there -- without access to the backend database?
Wrap the word Function in brackets like so should resolve the problem: [Function]
When you say the values of the field are blank do you mean on the display side in the repeater? Have you changed the transformation to use the new field name? Have you updated the Columns property of the repeater to use the new field name vs. the old one? It will not lose all the data, you just need to ensure all the values of the property/field name are updated everywhere including any custom code you might be using for this page type.

Remove a button in SuiteScript

I need to be able to remove the delete button when today is greater than a particular calculated date.
There are 2 ideas I had and issues with each:
1 - Set a custom field on the record for the particular calculated date. Then use a workflow action of Remove Button where the custom field is <= today. My issue is I am wondering if there is a way to get "today" because I expected the condition to change allowing me to do that. I tried to use a formula and can't find Now() as a valid function listed.
2 - Workflow are truly scripts in the background. That means the Remove Button should be available in API. Therefore, my idea was to do my conditioning in suite script and then call this function. However, this function also does not exist in supported form. Has anyone hacked this to find what the function that is called in Remove Button is?
If we can get either idea to work, or if you have a third I haven't thought of that accomplishes the same task, that would be great.
I figured out my own answer. In case someone else ever needs this (as I didn't see anything like this on stack overflow), here is how to do option #1:
Save the value to a custom field - custbody_block_dlt_date
In a workflow, use the Remove Button function and use a formula condition
The condition is: {custbody_block_dlt_date} < sysdate
"sysdate" is the way you can get "Now()" or "today" in the condition
An alternative could be to create a User Event Script, on the before load function, get the button object then use the .setVisible(visible) method to hide it based on a date criteria, you may also want to set other restrictions based on roles that allow certain individuals to still be able to delete the record, like high positioned accountants. That avoids creating unnecessary fields on your records, while still providing the functionality that you desire. This could easily be done in < 4 lines of JavaScript.
See nlobjButton for examples.

NotesViewColumn check if Total option is enabled

how can I check if something is selected there? I need at least 'fact': selected or not (and would be nice to know how to read real settings).
I looked into NotesViewColumn and did not find anything there, maybe it's undocumented feature :(
You can use DXL. The DXL schema for view columns includes an attribute that represents the selected option for the totals.
I.e. set up a NotesNoteCollection object that includes the view design note. Use NotesSession.CreateDXLExporter to get a NotesDXLExporter and process the NotesNoteCollection, parsing the XML to locate the column and get the value for the totals attribute.

Resources