is there a way to find out if field level security has been applied to a field in DCRM 2013?
I'm looking for something like:
Xrm.Page.getControl("controlName").isMasked()
You can use Xrm.Page.getAttribute("attributeName").getUserPrivilege(), which returns an object containing three booleans:
canRead
canUpdate
canCreate
In your case you could check the value of .canRead to figure out whether the user can see the contents of the field or not.
Related
OOUI's OO.ui.ComboBoxInputWidget allows to set an array of
OO.ui.MenuOptionWidget objects in its menu.items config field.
Such an item can have a label and a data field. The data field can
be of type object 1.
Now, if I use a data field of typeobject the value of the
OO.ui.ComboBoxInputWidget will be "[Object object]", as it tries to cast
the data value to a string when a user selects an option item.
So it looks like OO.ui.ComboBoxInputWidget allows only data of type
string in its options. Is that correct?
That would also mean that there is no "label/data" mechanism of the input
field itself. If I've got the following options
[
{ label: "Rot", data: "red" },
{ label: "Gelb", data: "yellow" },
{ label: "GrĂ¼n", data: "green" }
]
and the user selects the option with label "Gelb" the input field shows
"yellow", not "Gelb". The code example in the official documentation shows this behavior [2]. Did I miss something? Is it possible to show a
label to the user but retrieve the data (object) when calling
getValue on such a field?
1 https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.MenuOptionWidget-cfg-data
[2] https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.ComboBoxInputWidget
This question was originally posted on the wikitech-l mailing list. You can find the thread here: http://markmail.org/message/fesegc3yljqcytzt
In general, the 'data' property for items inside the GroupElement can be strings or objects, as they represent some state of your item. In OO.ui.mixin.GroupElement, the method getItemFromData can then return a specific item based on its data property. If you use an Object for the data, OOUI will use its OO.getHash() to basically stringify your object, so it can make sure it retrieves the right one.
The property 'data' actually comes all the way up the hierarchy chain from OO.ui.Element (if you look at that method, the description of that parameter is the same) -- and at that level, it definitely allows for any sort of data, be it a string or an object.
However, when dealing with specific cases, like that of the ComboBoxInputWidget (the terminology of "input widget" usually suggests something inside a form in OOjs-UI) means that putting the data as an object doesn't make sense usually. Unless your use case requires something very different, we usually want ComboBoxInputWidget to have the 'value' => 'label' pair, so it uses its 'data' property as the 'value' and expects a string.
As for the second part of your question, I am not 100% sure I understood it (please correct me if so) but from what I understand, if you set your OO.ui.MenuOptionWidget items with their data as the value ('red' / 'yellow' / 'green' etc) and the label as the mw.msg that the user sees, then it should work out of the box.
So if you look at the example given in the docs for ComboBoxInputWidget you can set your item's data to the color (value) and the label to the word you want to display, and when the user picks an option, the label needs to show in the ComboBoxInputWidget.
Be aware, though, that if you listen to 'choose' or 'select' event from this input widget, you get the selected item, so if you're projecting that choice into some other input, you should ask for the label (item.getLabel()) and not the data.
Thanks for your explanations.
It looks like OOUI does not support something like that (yet).
An example: You've got a option value "Q7186" and a label value "Marie
Curie". When the user selects "Marie Curie" the user interface will
say: "Q7186". A user might be confused.
I know that some UI frameworks handle this by showing the label of
the selected item to the user in a DIV element or something else and
storing the actual value in an internal variable. When it comes to form
submission and the need to provide an actual "value string" they use a
hidden field and maybe a valueField config option in case the "value"
is not a string but an object (thus allowing to set the string value of
the hidden field from a field within the value object).
Maybe that's something for future development.
This is my first time in this web site, I hope that you may help me. Thanks in advance. Mainly I need two things.
To create something with JavaScript for compare a field (inv_product.min_exi) from my database against existence of inventory. Wherein existence <= inv_product.min_exi.
And when existence <= inv_product.min_exi then send to email for several emails accounts
All in JavaScript because I'm using Pentaho
Thanks again.
Not sure if you need this solution : I have assume a DataGrid input passing the inventory value and used a JavaScript Step to compare the values (check the 2nd image). I have hardcoded the value of existence for testing purpose.If the condition is True, set a variable and then use a Filter Step to send out the mails.
This is a very simple example. Not sure if this is what you are looking for. By the question posted, if you are looking for doing all the above using JS, then you have to write codes for Mail in JavaScript.
Hope it helps :)
STEP by STEP Explaination:
Data Grid - it holds the input data. In your case, the values of "inv_product.min_exi". This can be any source.. You can use Table Input Step also and a PostgreSQl database.
Modified JavaScript Value - Use this step to do a initial checking condition. In your case "existence <= inv_product.min_exi". You can also do any other Javascript checkings. In the example i have given, i have considered the value of existence to be equal 2. But if the value of existence is dynamic or coming from a different source, you can remove this hardcoded value and use a dynamic input streaming.
Now if a condition is getting satisfied, you can assign a value to a variable like "flag_ex = 1" or "flag_ex=0".
Filter rows - You can filter out the input stream based on the flag_ex value. As per my example, if flag_ex=1 then it satisfies true else false.
Mail - Finally send out Mail of the True conditions.
How can I extract values from Global picklist in crm 2013? I update some text fields based on the value of the option set. Usually in local option set we can use the following code to update the fields based on the value of option set.
var value = Xrm.Page.getAttribute("new_optionset").getText();
if(value=="ABC"){
Xrm.Page.getAttribute("new_field1").setValue("Value");
Xrm.Page.getAttribute("new_field2").setValue("Some Value");
Xrm.Page.getAttribute("new_field3").setValue("Some Other Value");
}
But this does not seem to work if I am using a global option set. Is there another way of handling them?
From JavaScript there is no difference how to get the text between a local and a global optionset.
The syntax is the one you already know:
var value = Xrm.Page.getAttribute("new_optionset").getText();
If you want a library to manage the optionsets you can check this one I wrote:
http://gallery.technet.microsoft.com/scriptcenter/OptionSet-JavaScript-76af41f5
I have 2 textboxes, one which is required and the other one which is not required.
If we add text in the required text box, say "ABC", then remove the content, the ng-model is set to undefined
If we add text to the non required field and remove the content, the ng-model is not to empty string "".
Here is a plunk about the behavior I've explained above. Please use the console to look at the result.
http://plnkr.co/edit/XgQBfcyRF3OwG1qC0gXb?p=preview
Why is there a difference in setting the ng-model between the two?
It is seems to be by design, and has to do with a consistent behavior of validated form values.
There isn't anything on this behaviour in the docs, AFAIK.. It is implied here -> https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L1045
With angularJS validation, if a value entered on field is allowed, that becomes the model's value (as any other bound value would behave). If it isn't, the only way to be consistent is to set the value as undefined (as no allowed value is in the field). The two other options would be to keep it's last valid value, or keep binding the wrong value, only triggering the flags for invalid field, and form. Both these solutions are bad - leaving the last value is probably not wanted (if you were to use the values disregarding the state of the form, it would lead to errors) and allowing for invalid values is a terrible sin ;) (you couldn't trust the validation service to help prevent buggy use of wrong types)
Although it may seem strange or even inconsistent, it really isn't. I have slightly modified your plunkr to validate for a number, which I believe makes it clearer why it is this way: http://plnkr.co/edit/9gJmblUn9MUUeFt5lWJZ?p=preview.
So, in reality there is no difference - only in your second input an empty string is considered a valid, thus accepted value for that field.
I have a table of rows and columns on an HTML-based entry form that allows the user to edit multiple records. Each row corresponds to a database record and each column to a database field.
When the user submits the form, the server needs to figure out which request parameter belongs to which row. The method I've been using for years is to prefix or suffix each HTML input element's name to indicate the row it belongs to. For example, all input elements would have the suffix "row1" so that the server would know that request parameters whose names end with "row1" are field values for the first row.
While this works, one caveat of the suffix/prefix approach is that you're adding a constraint that you can't name any other elements with a particular suffix/prefix. So I wonder if there's a better, more elegant approach. I'm using JSP for the presentation layer, by the way.
Thanks.
I don't know JSP very well, but in PHP you would define your input fields' names with an array syntax.
<input name='person[]'>
<input name='person[]'>
<input name='person[]'>
When PHP receives a form like that, it gives you an array (within the standard $_POST array), thus:
$_POST['person']=array('alice','bob','charlie');
Which makes it very easy to deal with having as many sets of fields as you want.
You can also explicitly name the array elements:
<input name='person[teamleader]'>
<input name='person[developer1]'>
would give you an array with those keys. If your current prefixes are meaningful beyond simply numbering the records, this would solve that problem.
I don't know whether the identical syntax would work for JSP, but I imagine it would allow something very similar.
Hope that helps.
Current user agents send back the values in the order of the fields as presented to the user.
This means that you could (theoretically) drop the prefix/suffix altogether and sort it out based on the ordering of the values. You'd get something like
/?name=Tom&gender=M&name=Jane&gender=F&name=Roger&gender=M
I don't know how your framework returns that, but many return it as lists of each value
name = [Tom, Jane, Roger]
gender = [M, F, M]
If you pop an element off of each list, you should get a related set that you can work with.
The downside to this is that it relies on a standard behavior which is not actually required by the specification. Still... it's a convenient solution with a behavior that won't be problematic in practice.
When browsers POST that information back to the server, it is just a list of parameters:
?name_row1=Jeff&browser_row1=Chrome&name_row2=Mark&browser_row2=IE8
So really, I think you can answer a simpler question: how do you relate keys in a key-value list?
Alternatively, you can go to a more structured delivery method (JSON or XML), which will automatically give you a structured data format. Of course, this means you'll need to build this value on the browser first, then send it via AJAX (or via the value of a hidden input field) and then unpack/deserialize it in the server code.
XML:
<rows>
<row><id>1</id><name>Jeff</name><browser>Chrome</browser></row>
<row>...</row>
</rows>
or JSON:
[{ "name":"Jeff", "browser":"Chrome"}, { "name":"Mark", "browser":"IE8" }]
There are many resources/tutorials on how to do this... Google it. Or go with the ostensible StackOverflow consensus and try jQuery.