change value of one field on the basis of other using spfx field customizer - sharepoint-online

I have a field name called Security(choice field) and other field name is Sensitivity. I want to copy the values of Security in Sensitivity in the list view. For example if value of security is Internal then in sensitivity column also it should show Internal in the list view only irrespective of the values stored in sensitivity. In laymen term Both field should show same values. I am new in spfx environment. Please help. I am using react framework. Let me know if you need any other details.
PS- I have 400k libraries consisting same column with same internal name so column formatting option is not suitable. we need o deploy as an extension so that it will change listview across all libraries.

In SPFx Field Customizer, implement the onRenderCell with below logic:
The method has signature as follows:
public onRenderCell(event: IFieldCustomizerCellEventParameters): void
Use below code to get the Security field value:
const securityValue = event.listItem["_values"].get("Security");
Once you get the item id, you can get the value of other field from same item.
Return the value as:
event.domElement.innerHTML = `<div>${securityValue}</div>`
Source: change value of one field on the basis of other using spfx field customizer

Related

IBM Maximo Lookup selecting another value not default value

I am trying to create a lookup. I want to select from PERSON table - if I select a value through lookup, person id is selected, but I need display name value. I have tried by creating a table domain, lookup table, lookup.XML and all methods.
If you need the DisplayName copied to the local object in addition to the PersonID, then instead of a Table Domain, you need a Crossover Domain with DisplayName as a Source Field and with your local attribute that should hold the copy of Person.DisplayName as the Target Field.
If you need the DisplayName copied to the local object instead of the PersonID, then you'll need to make a lookup map on the target attribute so Maximo knows what attribute returned by the domain maps to which attribute on the local object. You set Lookup Maps with the little, white, "page" icon/button on the right side of the Attributes tab in Database Configuration for the desired target attribute.
If you just need to see the DisplayName once a PersonID is selected, then use a Mulitpart Textbox and set "Attribute for Part 2" to something like PERSON.DISPLAYNAME, where PERSON is the name of the relationship from the local object to the PERSON object.
As Preacher already mentioned, you can copy the DISPLAYNAME attribute using a lookup map - on the Database Configuration application, go to the attribute to which you want to copy - probably the one, where you used the table domain on - and click the icon.
If you have created a custom field and have no Java class on it, you will still need the table domain, so leave that on the attribute. Now, on the lookup map, you can define which fields you want to copy from the source MBO to the target MBO. You can define multiple target fields from here (so no need to define a crossover domain, even if you need to copy multiple fields) - just enter a new line for any field you want to copy from the source (Person) object.
On many versions of Maximo you will have to restart before this starts working! I believe you don't have to restart on 7.6, but on any previous version you will probably have to.
Now, about the definition in lookups.XML: if you want to show different attributes than the ones, already shown on the default "person" lookup, you need to define your own, as you did. If the default one looks fine, for you, you can just use "person" as the lookup, since the logic of copying fields is defined in the lookup map, not in lookups.XML.

Finding Lookup item numerical values in MS Dynamics

I have a site powered by ExpressionEngine 2.5.x, using Freeform, integrated to post form data to MS Dynamics CRM 2011. The extension is nicely scalable, I can change the mapping, all that excellent stuff. My problem is how to find mapping values for Lookup fields in MS Dynamics.
I am trying to map form fields from the site forms, into MS Dynamics. Some of the fields are Lookups, in MS Dynamics. Our mapping calls out the numerical value of the Lookup item, rather than its name. (Which is good, because ppl can change the text names in the MS Dynamics console without breaking the mapping.)
My question is: I know how to find the actual back-end field names of form fields within MS Dynamics. But how to I find the numerical values of the picklist items and lookup fields? Say I have a Lookup field, for Lead Source (called campaignid). The items are:
web
online
radio ad
flyer
word of mouth
other
I know that when I edit options in an option set, I can see their numerical value. Where can I edit options in a lookup field? I've tried looking under Settings > Customizations > Customize the System, but didn't see anything called lookup.
Lookups are pointers to entities. They do not have numerical values like regular option sets. So I guess that you will have entity called Campaign (or lead) so you can check which campaigns exist in the crm DB where each entity will have view in the DB.
Let's see if i understand your question. You don't have a Lookup option like Option Set because a lookup is consequence of a relationship 1:N between two entities. So for edit a lookup you need edit a record of a entity. In lookup fields you don't have numerical values, you have guid that represent individually a record, so in a record a lookup is stored in database as a guid. Check this video.
Check here how find this guid with the record open.
A look-up field is, roughly speaking a pointer to en entity (in C# it's referred to as EntityReference instead of Entity) and it consist mainly of a guid and logical name of something.
Usually, in the code, when you have an entity, in order to access the fields of its lookup-connected entity, you'll need to make an extra query for that.
So, if you have a Contact instance and need to see the address of its parent customer, you'll have to get the guid and logical name (in this case it'll be Account) and retrieve the data for it separately.
EDIT:
Suppose that you have created an instance of Contact entity and you'd like to access its lastName field. Then you can simply refer to it as follows.
var value = Xrm.Page.getAttribute(“lastName”).getValue();
On the same form, there's also a field that refers to an Account instance (its name is parentCustomerId. Suppose now that you'd like to get the fullName field of the Account. One could expect the following to work.
var account = Xrm.Page.getAttribute("parentCusomterId").getValue();
var name = account.getAttribute("fullName").getValue();
However, that's not going to work, because the parentCutomerId is a look-up field. It means that it only contains a guid (a pointer, a reference) identifying an other entity. You'll have to use it (the guid) in order to fetch the instance that the look-up is "mentioning". Then you'll be able to check it's properties.

lookup in Sharepoint, query SP list in workflow

I have two Sharepoint lists - ListA and ListB.
ListA has columns productName, productType. ProductType is made of choices (TypeA, TypeB, TypeC). Each product must belong to only one type. He gives Product Name and ProductType(from Selection) during adding products to ListA. ListB has columns RequestName, RequestDate, ProductName. ProductName is simply lookup to the ListA.
In ListB while adding new item,I first want to select productType and then display products of this type only. But, I couldn't find any ways to do this. Is there any way to do this, even programmatically.
OR alternatively, actually I don't need productType information in ListB. I am making workflow that uses ListB and that starts automatically when I add requests to ListB (he selects productName, and give RequestName and RequestDate). Then, in workflow, I have to check if the productName is of typeA or typeB or typeC, since I need this productType information to make some decisions in Workflow. Is there any way to get productType information from only productName using ListA and ListB.
Since this productName is unique, in Sql, it would be something like this
select productType from ListA where productName="selectedProduct"
but I have no clue if I can do some query in Lists in SP and get this result, store it in variable and use this later on.
Thanks
Note : For someone interested in cascading lookups in Sharepoint using Infopath forms, look here http://blog.libinuko.com/2010/07/21/sharepoint-2010-how-to-create-cascading-lookup-field/
If you have medium to advanced programming skills, you can achieve this by creating a custom field type. The basics are outlined in this article: http://msdn.microsoft.com/en-us/library/gg132914.aspx
Basically, a custom field type is made of:
an xml file defining the field name, properties and some other settings
a class inheriting from SPField (this is the actual field)
a field control (this is what you see on the new/edit listitem forms)
a field editor control (this is what you see when you create or modify the field, where you set the field properties)
a field value class
Some of those components are optional. In your case, you'll probably want to create a field that inherits from SPFieldLookup and create a custom field control and a custom field editor control. There's no need for a custom field value class, since you'll use the SPFieldLookupValue class.
A quick search on Google (or the search engine of your choice) can give you lots of detailed information and tutorials about the art of creating custom field types.
I would suggest using one of the cascading lookup fields available as 3rd party products, such as this one (i admit, this one is made by our company). Then you can have your product name column filtered by the Product Type column. No custom development required, you will just need to make some small changes to your lists (such as create a Product Types list and look it up, instead of using a choice column)

string;# in dropdownlist

I made a custom dropdownfield. I want to display the full names of my contacts. I made a calculated column because not every user filled in their full name, only first and last. If I wanna show the items in my dropdown there is always string;# before my value. Does somebody know how to remove that?
Here is the code where i fill my dropdown
SPWeb web = site.OpenWeb();
SPDataSource dataSource = new SPDataSource();
dataSource.List = web.Lists["Contacts"];
this.testing.DataSource = dataSource;
this.testing.DataTextField = "Full Name";
this.testing.DataValueField = "Full Name";
this.testing.DataBind();
thx
The field type is probably "User" (I think shows as "People" in the UI). This and other lookup fields are always stored by SharePoint in this manner. The value component is the user ID and the string component is the user name.
You could use a Regex to split the components. You can also cast the value to SPFieldUserValue which is the 'proper' way, and use the properties on that class to retrieve info.
Assuming full name is a text field, it looks like you have an error in your calculated column definition related to one of your inputs being a lookup field.
If you can't get rid of it in a cleaner way, there's always substr (or maybe right, I can never remember the syntax for excel functions)

Controlling how custom field types are rendered when exported to spreadsheet

I've created a custom field type based on SPFieldLookup. When I use SharePoint's "Export to Spreadsheet" function, however, it's not rendered correctly.
For normal lookup fields, only the Lookup Value is rendered. For my custom field, the string representation of the lookup value is used (i.e., "1;#My Lookup Value").
Is there a way to change the custom lookup field so that it will render only the Lookup Value when exported to a spreadsheet?
I'm not sure if its possible to do what you want.
Here's a note from the SPFieldLookup documentation on MSDN:
Notes to Inheritors: In Windows SharePoint Services 3.0, columns based on custom field types do not appear in Datasheet view and are not included when you export a list to a Microsoft Excel spreadsheet.
Maybe you can look into the DisplayPattern element in your fldtypes_XXX.xml

Resources