How to set RelationshipDeleteBehavior on a list using a site column and content type programatically CSOM c#

On Prem development machine, I'm writng a deployment routine in c# using the client object model.  I've created some site columns of type Lookup, I've created a content type and added those lookup columns to it and I've created a list using the
content type.  I want to set the RelationshipDeleteBehavior property on some of the lookup columns in the list.  I'm also using the 16 assemblies.
List list = cc.Web.GetListByTitle("MyList");
cc.Load(list);
cc.ExecuteQuery();
Field f = list.Fields.GetByInternalNameOrTitle("MyLookupField");
cc.Load(f);
cc.ExecuteQuery();
(f
as
FieldLookup).RelationshipDeleteBehavior =
RelationshipDeleteBehaviorType.Restrict;
f is returning as a Field but (f
as
FieldLookup) is returning null here.  Any insight on this?
Thank you.
Dan Budimir

Hi,
We can use SP.ClientContext.castTo method to convert the field to lookup field . The following code snippet for your reference:
ClientContext context = new ClientContext("http://siteurl");
NetworkCredential credentials = new NetworkCredential("username", "password", "domain");
context.Credentials = credentials;
Web web = context.Web;
List list = web.Lists.GetByTitle("MyList");
Field field = list.Fields.GetByInternalNameOrTitle("MyLookupField");
FieldLookup lookupField = context.CastTo<FieldLookup>(field);
lookupField.RelationshipDeleteBehavior = RelationshipDeleteBehaviorType.Restrict;
lookupField.Indexed = true;
lookupField.Update();
context.ExecuteQuery();
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support

Similar Messages

  • How to create two level dynamic list using JSP , Java Script and Oracle

    I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
    Plz response with details.

    1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
    2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
    3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
    4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
    5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
    6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
    You don't need Javascript for this.

  • Any ideas of how to set up a meal list in Numbers?

    Hey.
    I just got Numbers and I love it. This app is great.
    Does anyone have an idea of how to set up a meal list for a family in Numbers? I used to use TextEdit to type the meals in, separated with hard returns. It was one long list. I'd like to use someething a little more robust.
    Any ideas?

    Hi Ashka.
    Thanks, that's giving me some ideas. Sometimes I overcomplicate my thought process, only to streamline it once I've gotten the big picture. Your idea looks very close to what I can use.
    In the meantime, I made two weeks worth of breakfast, lunch, and dinner ideas. That helped me tremendously. I made a grocery list, based loosely off of the menu template, as Johnny mentioned above. It has an ingredient column (that lists all of the things that I would purchase), Have it column (with checkboxes. I'm sure that I'll be able to sort by that, later), Quantity (how many or much I'll need), How sold (pound, box, can, pieces...), Price, Estimate, and Store (you like the check boxes, I LOVE the selection menus! I set the cells in this column to have a list of the stores that I shop from. When I get to a particular item I choose the store from the selection menu. I love it!).
    Thanks for the help!
    -Scott

  • I cannot figure out how to set my apple id to use: itunes (two of accounts), apps store and Itunes store. How do I make one password that will be recognixed by all these devices?

    I cannot figure out how to set my apple id to use: itunes (two of accounts), apps store and itunes store. How do I make one password that will be recognized by all these devices? My apple id is constantly not working.

    Hi Lrwill,
    If the apps that are on your son's iPad were purchased under his Dad's Apple ID, then signing your Apple ID onto the iPad will not help you with updating those apps.
    Also, if the iPad was sync'd with his Dad's iTunes library, then hooking it up to your computer/iTunes library, will require you to reset the iPad, and everything that was loaded under the other Library and Apple ID will be wiped out.
    Can you provide a little more info about what was set up under which Apple ID and what iTunes library the iPad was sync'd with?
    Cheers,
    GB

  • How to set up different virtual LANs (using the E3200)?

    Hi.
    I would like to set up different virtual LANs (using the E3200) so that I can have two different networks that can't access each other.
    The E3200 is connected to a modem for internet access.
    I would like both networks to have access to the internet.
    Does the E3200 alone support creating virtual LANs?
    If not, is there another way I can meet the requirement using the E3200 alone (using something other than virtual LANs)?
    I'm ultimately thinking that I would need at least one other router.
    So for example,
    Router A (E3200) is connected to the modem and setup for DHCP using a LAN IP range 192.168.1.1/24.
    Router B is connected to Router A and setup for DHCP using a LAN IP range 192.168.2.1/24.
    In this way devices connected to Router A should not have access to devices connected to Router B and visa-versa, correct?  For example, Device X connected to Router A cannot ping or browse files on Device Y connected to Router B and visa-versa, correct?
    Would I need to setup anything else on Router B?  For example, do I need to setup DNS settings so that devices connected to Router B can connect to the internet without issue?  Would I need to specify that these virtual LANs are not bridged, and on which router, or both?
    I already know how to set up a static IP, DHCP, LAN IP ranges, and static DNS settings on a router, etc.
    In regards to wireless devices, I am thinking they would follow the same pattern; so wireless devices connected to Router A (E3200) have access to other wired and wireless devices connected to Router A but not to wired or wireless devices connected to Router B and visa-versa.  However, if wireless devices currently don't have access to wired devices also connected to Router A, then that is fine for now.
    Thank you very much!
    -Rami
    Solved!
    Go to Solution.

    The E3200 has no VLAN support according to the manual. There's no way to configure two separate networks with this router alone.
    You will need to add network electronics.
    Ex:
    Managed Switch with VLAN
    Another wireless router with VLAN
    If your modem supplies multiple public or private IP addresses then you could put a switch after the modem and two wireless routers attached to the switch.
    Please remember to Kudo those that help you.
    Linksys
    Communities Technical Support

  • How to set a foot in a scrolling page site, that it remains visible even when scrolling, using PC

    how to set a foot in a scrolling page site, that it remains visible even when scrolling, using PC

    Hello,
    Please select the footer items and Pin them to the bottom like the screenshot below.
    Regards
    Vivek

  • How to Enable Ratings on SharePoint List using Client Object Model for Office 365 SharePoint Site.

    How to Enable Ratings on SharePoint List using Client Object Model code for Office 365 SharePoint Site.
    Thanks in Advance
    Rajendra K

    Hi Rajendra,
    here you are the code and the blog, let me know if this helps
    using (ClientContext ctx = new ClientContext(https://yourSiteUrl))
    Web w = ctx.Web;
    List l = w.Lists.GetByTitle("yourListName");
    ctx.Load(l, info => info.Id);
    ctx.ExecuteQuery();
    string ListID = l.Id.ToString();
    Microsoft.Office.Server.ReputationModel.Reputation.SetRating(ctx, ListID, 1, 5);
    ctx.ExecuteQuery();
    http://blogs.technet.com/b/speschka/archive/2013/07/08/how-to-use-csom-with-ratings-in-sharepoint-2013.aspx
    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

  • How to set Border in the Excel using UTL_FILE ?

    Hi all,
    Any one aware of
    How to set Border in the Excel using UTL_FILE ?
    Am doing excel creation from a stored procedure.
    Thanks
    Dora

    Hello Dora,
    if you need more than simple csv: at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the package behind the second link supports defining your own formats (and has a tutorial how to do it).
    Regards
    Marcus

  • How to set the full screen mode using setClip method

    hi all,
    how to set the full screen mode using setClip in that softkeys should not be used insteat on that need to create a own softkeys using commands.
    thanks & regards
    Bala.

    In CS5 there are changes made to how the screen mode is reported. In CS3-CS5 the screen mode has a corresponding number. So for instance if the ScreenMode is set to "Preview Off" and you ask indesign CS3 or CS4 to display the screen mode, it will report "1936552047", while in CS5 it will report "PREVIEW_OFF".
    try executing this simple command in respectively CS3, CS4 and CS5 and you will see what I am talking about:
    alert(app.activeWindow.screenMode);
    there is no difference if you do:
    alert(app.activeDocument.layoutWindows[0].screenMode);
    The CS5 solution is rather awkward to work with, unless I am missing something? PREVIEW_OFF is not a string, nor is it a number.
    Example -  doing:
    myScreenMode=app.activeDocument.layoutWindows[0].screenMode;
    and then trying to reset screenMode by something like:
    app.activeDocument.layoutWindows[0].screenMode= myScreenMode
    does not work in CS5 of course. It will throw an error. Neither will this line work:
    app.activeDocument.layoutWindows[0].screenMode=ScreenModeOptions.myScreenMode;
    Any way of working around this?

  • How to Set "DateOnly" property in DateTimeControl using Javascript.

    How to Set "DateOnly" property in DateTimeControl using JavaScript.

    Is there any specific reason you want to set it through JavaScript ? You can directly set the DateOnly property in the markup itself.
    <SharePoint:DateTimeControl runat=server id="dtControl" DateOnly="true"></SharePoint:DateTimeControl>
    Please can you elaborate on what exactly is the requirement for setting this through javascript?
    Geetanjali Arora | My blogs |

  • How to set up a mail server with a private DNS and relay over a public mail

    How to set up the mail server that we can send and pick up emails inside and outside?
    Our private network has the DNS name dnsname1.private.
    We have our privat DNS Server and he can forward requests to outside over our router.
    Our public emails are hosted by an internet provider. This dns name is dnsname2.com and dnsname2.org.
    How we have to set up our mail server that we can pick up our emails from our public dnsname2.com?
    And when we write an email how we have to set up it that the dnsname is dansname2.com and not dnsname1.private?

    If you want to move your mailservice to your own (internal) server, start by making sure you can recieve traffic on port TCP 25 (SMTP). Some ISPs blocks this port, especially on "non business" connections.
    Can you send mail from your LAN directly to where your mail is hosted using port 25 TCP or do you have to relay via your ISP?
    You have a static public IP?

  • How can set screen resolution on firefox , i know zoom in and out but i want set my broswer to my favorie levelof zoom

    hi
    how can set my firefox screen resolution ( i know zom in and zom out but when i restart my firefox , it chanaged to perviose level of zoom )

    In case you are using "Clear history when Firefox closes":
    *do not clear the Site Preferences
    *Tools > Options > Privacy > Firefox will: "Use custom settings for history": [X] "Clear history when Firefox closes" > Settings
    *https://support.mozilla.org/kb/Clear+Recent+History
    Note that clearing "Site Preferences" clears all exceptions for cookies, images, pop-up windows, software installation, and passwords and website specific setting like the page zoom.
    Clearing cookies will remove all specified (selected) cookies including cookies with an allow exception.

  • Problem with setting up new Ipad Air2:I can't set up my new Ipad using new Apple ID and it keeps showing the notification that wrong email or password and try again. I can log in Itune with thesame

    I can't set up my new Ipad using new Apple ID and it keeps showing the notification that wrong email or password and try again. I can log in Itune with the same ID. Please help me if you have come across the same issue. Thank you!

    Contact the App store for Apple ID help. Their support link is on the right of the App store window
    LN

  • How to set up the interaction between InDesign CS6 8.0 and Photoshop CS 6 - if Photoshop is installed and the 64 and 32-bit?? default InDesign refers to the 64-bit version of Photoshop and scripts do not work.

    how to set up the interaction between InDesign CS6 8.0 and Photoshop CS 6 - if Photoshop is installed and the 64 and 32-bit?? default InDesign refers to the 64-bit version of Photoshop and scripts do not work.

    Nice of you to point it out here as I at least don’t follow Mr.Nash’s blog regularly.

  • How to prevent user or group to use 3-tier WebI and DeskI in XI 3.1

    How to prevent user or group to use 3-tier WebI and DeskI in XI 3.1
    This function is enable in BOE 6.5 by using Supervisor.

    Hi,
    You can explicitly deny access to these applications from the CMC in BOE 3.1. Open the CMC, click on BusinessObjects Enterprise Application and then select the WebI.
    From the right hand side click on the 'Net Access' section for that group and disable the 'Log on to Web-Intelligence and view this object in CMC.'
    This will prevent the option of the WebI for that group.
    I hope this helps you.
    Regards,
    Prashant

Maybe you are looking for