Check the type of column using powershell within a splist

hi,
i have a column called BU in my splist in many site collections.i had created using with lookup datatype and  now  since my design is changed i  want to create this as  a a choice field with few default values. Can anyone please
help how to check this using powershell? i mean check the  datatype of  column using PS and  if its lookup then need to delete the list and recreate it with choice field. i know hot to create a splist with choice field using PS,
but  i am unable to get the code for existence of lookup or choice field.
$web = Get-SPWeb "http://sitename"
$fieldnamebu= "BU"
$mysplist = $web.lists["mysplist1"]
$lookupfieldA="Lookup"
foreach($sfield in $mysplist.fields)
# how to check the datatype pf column as lookup
if ( ##todo#### -eq $lookupfieldA )
$mysplist.Delete();
$web.upate();
create the splist with choice field$spTemplate = $web.ListTemplates["Custom List"] #Create SPTemplate instance of Type Custom List
$web.Lists.Add("mysplist1", "for approvers", $spTemplate)   #Add list to site$spList = $spWeb.Lists["mysplist1"]    #Get list instance
$spList.OnQuickLaunch = $True   $spList.Update()    #Update list to reflect changes in site
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text      #Get Field type to create
$spList.Fields.Add("Mymn", $spFieldType, $false)      #Add new field to list}

HI,
To get the field types please refer below link...
foreach ($field in $list.Fields) #Get all fields in lists
if($spField -eq $field.Title) #if field in lists equals field in views
Write-Host $spField " | " $field.Type -ForegroundColor Green #Write out each field (column)
https://gallery.technet.microsoft.com/office/SharePoint-Get-SPFields-49039dc0
To Create Choice field follow below reference:
https://social.msdn.microsoft.com/Forums/en-US/8a874677-91cf-41dd-a601-f0dd7fdce213/creating-a-choice-column-via-powershell
http://adicodes.com/add-fields-to-list-with-powershell-in-sharepoint-2010/
Don't
forget to mark it as an Answer if it resolves your issue and Vote Me as helpful if it useful.
Mahesh

Similar Messages

  • How to know whether the Content Type at Library level is Inheriting Parent Content type or not Using Powershell?

    Hi,
    How to know whether the Content Type at Library level is Inheriting Parent Content type or not using Powershell?
    Is there any property for that? Or Do I need to compare the Content type Id's at Site collection level and Library level?
    Any help would be greatly appreciated.
    Thank you,
    AA.

    Hi Ashok,
    For a content type, there is an attribute called Inherits, the value of this attribute determines whether the content type inherits fields from its parent content type when it is created.
    If Inherits is TRUE, the child content type inherits all fields that are in the parent, including fields that users have added.
    If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was
    installed. The child content type does not have any fields that users have added to the parent content type.
    More information, please refer to the link:
    https://msdn.microsoft.com/en-us/library/office/aa544268.aspx?f=255&MSPPError=-2147217396
    Best Regards,
    Wendy
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to know or check the type of a field when processing a dynamic table?

    Dear all,
        When processing a dynamic table i have a short dump because of a convert_of_type incorrect, so i would like to check the type of field-symbol <f> before moving the data (type char) to this field-symbol <f>.
    Could you please help me how to check or get the type of field-symbol <f> (because field-symbol <f> is assigned dynamic, so this <f> can be type char, unit, or quantity, ...)?
    The source code same as below:
       ASSIGN COMPONENT lc_field OF STRUCTURE ls_data TO <f>.
       MOVE lv_field TO <f>. (Dump is here when lv_field is char type and <f> is quantity type => could i check the type of <f> if it's char type before using this instruction "MOVE ..."?)
    Thanks a lot in advance,
    Vinh Vo

    Try to use this way
    WRITE lv_field TO <f>.
    Instead of
    MOVE lv_field TO <f>.

  • How to check the type of uploaded file

    Hi, experts,
    how can I check the type of the uploaded file? I am dealing with exception handling now: when user uploads a type of file which is not allowed, then error msg shows up. So first I have to retrieve the type of the uploaded file.
    Best regards,
    Fan

    Best approach would be to control the file upload program. Here in force user to chose only the kind of file supported.
    If you are using WD4A & fileupload UI element, then after user select a file to upload, before processing the file you can check the file name and get its MIME TYPE as shown below.
    example
    data type file string.
    data dot_offset type i.
    data extension type mimetypes-extension.
    data mimetype type mimetypes-type.
    file = 'Image.jpg'.
    " Find out file name extension
    find first occurrence of regex '\.[^\.]+$' in file match offset dot_offset.
    add 1 to dot_offset.
    extension = file+dot_offset.
    " Get mime type
    call function 'SDOK_MIMETYPE_GET'
      exporting
        extension = extension
    importing
        mimetype  = mimetype.
    later using if/else or CASE statement define your logic.
    Greetings
    Prashant
    P.S. Points Welcome

  • Exception: "The type "Collection" as used in the variable/parameter declarations

    I am getting the following exception when I try to run the test code.
    What could be causing it ?
    I am running Kodo 2.4.3 with JDK 1.4.1
    EXCEPTION
    javax.jdo.JDOFatalInternalException: [agencyNames:[AGENCY1, AGENCY2]]
    NestedThrowables:
    javax.jdo.JDOUserException: The type "Collection" as used in the
    variable/parameter declarations could not be found in the imports.
    TEST CODE
    JDOFactory jdoFactory = new JDOFactory();
    PersistenceManager pm = jdoFactory.getPersistenceManager("");
    try
    Class agencyClass = Agency.class;
    Extent agencyExtent = pm.getExtent(agencyClass, false);
    String filter = "agencyNames.contains(agencyName)";
    List agencyNames = Arrays.asList(new String[]{"AGENCY1",
    "AGENCY2"});
    String param = "Collection agencyNames";
    Query q = pm.newQuery(agencyExtent, filter);
    q.declareParameters(param);
    Collection deps = (Collection) q.execute(agencyNames);
    System.out.println("SIZE :" + deps.size());
    catch (Exception ex)
    ex.printStackTrace();
    JDO Mapping and Class
    package test;
    import java.util.*;
    public class Agency
    private String agencyName;
    private String hostCarrierCode;
    //Getter and Setter
    public static class Id
    public String agencyName;
    public String hostCarrierCode;
    //Application ID definition
    ?xml version="1.0"?>
    <jdo>
    <package name="test">
    <class name="Agency" identity-type="application"
    objectid-class="Agency$Id">
    <extension vendor-name="kodo" key="table" value="AGENCIES"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="agencyName" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="AGENCY_NAME"/>
    </field>
    <field name="hostCarrierCode" primary-key="true" >
    <extension vendor-name="kodo" key="data-column"
    value="CARRIER_CODE"/>
    </field>
    </class>
    </package>
    </jdo>

    Kodo 2.4.3 does not support using collections as parameters.
    Kodo 2.5.0, due to be released shortly, does support this. See
    http://solarmetric.com/Software/beta/2.5.0 to get the latest release
    candidate.
    -Patrick
    On Thu, 05 Jun 2003 22:26:36 +0000, B K Adarsh wrote:
    I am getting the following exception when I try to run the test code.
    What could be causing it ?
    I am running Kodo 2.4.3 with JDK 1.4.1
    EXCEPTION
    javax.jdo.JDOFatalInternalException: [agencyNames:[AGENCY1, AGENCY2]]
    NestedThrowables:
    javax.jdo.JDOUserException: The type "Collection" as used in the
    variable/parameter declarations could not be found in the imports.
    TEST CODE
    JDOFactory jdoFactory = new JDOFactory();
    PersistenceManager pm = jdoFactory.getPersistenceManager("");
    try
    Class agencyClass = Agency.class;
    Extent agencyExtent = pm.getExtent(agencyClass, false);
    String filter = "agencyNames.contains(agencyName)";
    List agencyNames = Arrays.asList(new String[]{"AGENCY1",
    "AGENCY2"});
    String param = "Collection agencyNames";
    Query q = pm.newQuery(agencyExtent, filter);
    q.declareParameters(param);
    Collection deps = (Collection) q.execute(agencyNames);
    System.out.println("SIZE :" + deps.size());
    catch (Exception ex)
    ex.printStackTrace();
    JDO Mapping and Class
    package test;
    import java.util.*;
    public class Agency
    private String agencyName;
    private String hostCarrierCode;
    //Getter and Setter
    public static class Id
    public String agencyName;
    public String hostCarrierCode;
    //Application ID definition
    ?xml version="1.0"?>
    <jdo>
    <package name="test">
    <class name="Agency" identity-type="application"
    objectid-class="Agency$Id">
    <extension vendor-name="kodo" key="table" value="AGENCIES"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="agencyName" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="AGENCY_NAME"/>
    </field>
    <field name="hostCarrierCode" primary-key="true" >
    <extension vendor-name="kodo" key="data-column"
    value="CARRIER_CODE"/>
    </field>
    </class>
    </package>
    </jdo>--
    Patrick Linskey
    SolarMetric Inc.

  • Which Java API could check the type of Operating System the JVM is running?

    Does anyone know which Java API could check the type of Operating System the JVM is running?
    thanks a lot!

    check out System class.
    regards
    shyamAnd specifically, the getProperty() method.
    - K

  • How can I change the type of column in matrix

    I want to change the type of column in matrix to it_LINKED_BUTTON, so it can show the orange arrow
    I added the column throw marketing documents (rows)
    It's seems the default column type  is it_Edit
    is there a way of changing the column type
    i tried the below code, but it did not work because the type property in a matrix column is readonly
    mtx.Columns.Item(0).Type = SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON
    sincerely yours
    Riade Asleh

    i don't want to add a new column
    i want to change the column type of existing column in matrix, becuase it's bind to a field
    beside that, i can not add column , if the matrix has rows in it
    sincerely yours
    Riade Asleh

  • How can I check the virtual-address up using show command in ACE?

    I want to check the virtual-address using show command.
    however, there are not in ACE. So I used the ping to check virtual-address status in ACE
    I want to know the command what is verify virtual-address status , using show command
    Thank :)

    Try -> show arp
    There you have a Type column and a Status column.
    Look for the entry "VSERVER" in the Type column
    Roble

  • Creating look up column using powershell.

    I have a Sharepoint list "Studentparent" in my website. I am trying to create a custom list "studentchild" list using powershell code and this studentchild list will be having a look up column getting ID column from "StudentParent"
    list - So the code is 
    #To which site u want to create the list 
    $spWeb=Get-SPWeb -Identity http://XYZ
    #List type or template 
    $spTemplate = $spWeb.ListTemplates["Custom List"]
    #Get all the lists to the listcollection
    $spListCollection=$spWeb.Lists
    #adding the new list to the list collection
    $spListCollection.Add("StudentChild","StudentChild",$spTemplate)
    #get the path of subsite and sitecollecion 
    $path = $spWeb.url.trim()
    #get the list to the list object
    $spList = $spWeb.GetList("$path/Lists/StudentChild")
    $ParentList = $spWeb.Lists.item("StudentParent")
    $spList = $WebObj.Lists["StudentChild"]
    $spList.Fields.AddLookup("ChildLookupField",$ParentList.id,$false)
    $spChildListLookupField = $spList.Fields["ChildLookupField"]
    $spChildListLookupField.LookupField = $ParentList.Fields["ID"]
    $spChildListLookupField.RelationshipDeleteBehavior = [Microsoft.SharePoint.SPRelationshipDeleteBehavior]::Restrict
    $spChildListLookupField.Update()
    $Views = $spList.Views["All Items"]
    $Views.ViewFields.Add("ChildLookupField")
    $Views.Update()
    but when i run this code - I am getting error
    Cannot index into a null array.
    + $spList = $WebObj.Lists["StudentChild"]

    Hi Mahesh,
    The object "$WebObj" is not instantiated in your code. You have already assigned the value to $splist in following line.
    $spList = $spWeb.GetList("$path/Lists/StudentChild")
    and once again you are assigning value
    $spList = $WebObj.Lists["StudentChild"] // redundant and it should be $spWeb.Lists["StudentChild"]
    Please let us know if this fixes your issue.
    Thanks,
    M. Gubendra Raj

  • How can I check the progress of a Loader from within a movie clip?

    Hi All,
    I have a Loader called profileContentLoader that I create in AS3 on the main timeline, I would like to check the bytesLoaded of profileContentLoader from within a movieclip thats in another movieclip....
    I tried:
    MovieClip(root).profileContentLoader.bytesLoaded
    but that doesn't work....
    Thanks for any help

    The Loader class uses a LoaderInfo class object to do its loading event informational bidding.  Look into the contentLoaderInfo property of the Loader class and then followup looking at the LoaderInfo class to see what you can make use of from it.

  • Cannot delete Document Content Type. Getting error "Document Content Type Still in use" powershell, sharepoint 2013

    not able to delete "Document" content type from a library. I have a custom content type. I have added the custom content type to all the items of library. also, i have added the custom columns from "Document" content type to my custom
    content type. Still cannot delete the "Document" content type. I am doing the same process in different site collections and different libraries. But not able to delete in a few say- 10 in 100. Get the error - "Document content type is still
    in use"

    Hello 
    Here you go
    http://blog.octavie.nl/index.php/2012/09/14/error-the-content-type-is-in-use-explained
    https://social.technet.microsoft.com/Forums/en-US/e81020e3-2c12-4f39-a2f4-f1fd88ba6547/content-type-is-still-in-use-on-document-library
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Update workflow status column using PowerShell

    Hi All,
    Using PowerShell i want to update the 'Document Status' column as 'Approved'  if it is 'Pending' when it is approved and Task Status is = 'Completed'
    Intermittently my custom workflow is not updating the 'Document Status' column as 'Approved' though it is approved and Task Status is = 'Completed'
    So I thought about running a PowerShell script to work around it.
    Can you please help me for the script.
    Thanks & Regards
    MD.Liakath ali

    Hi,
    The following PowerShell script for your reference:
    $SPWeb = Get-SPWeb http://site
    $List = $SPWeb.Lists["ListName"]
    $items = $List.Items
    foreach ($item in $items) {
    $taskStatus = $item["Task Status"]
    $docStatus = $item["Document Status"]
    if ($taskStatus -eq "Completed" -and $docStatus -eq "Pending")
    $item["Document Status"] = "Approved"
    $item.Update()
    $list.Update()
    $SPWeb.Dispose()
    If the 'Document Status' column is "Approval Status" column and your workflow is an approval workflow, the following articles may be helpful:
    Approval workflow does not update the approval status of items
    https://kanithi.wordpress.com/2014/03/13/approval-workflow-does-not-update-the-approval-status-of-items/
    SharePoint 2010 Approval Workflow with Content Approval
    https://eointherealworld.wordpress.com/2010/12/29/sharepoint-2010-approval-workflow-with-content-approval/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Can't find the type wsrc_runtime_attr_varray for using the wwrc_api API

    hi,
    I manage to build a custom search portlet in PL SQL that can search for items and filter on their attributes.
    everything works lovely and I'm at the final stage : performing the search !
    I plan to use the wwsrc_api.item_search procedure and specify attributes with the
    wwsrc_api.specify_attributes.
    (see the doc on > http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1014/wwsrc_api.html#procedure-specify_attributes )
    The problem is when calling teh specify_attibutes procedure, I can't declare the last (but not the least) parameter. It's type is wsrc_runtime_attr_varray and I can't find it anywhere in any schemas of my DB.
    here is the signature of the procedure :
    procedure specify_attributes(
    p_id in number,
    p_siteid in number default wwsbr_site_db . shared_siteid,
    p_value in varchar2,
    p_operator in varchar2 default contains_all,
    p_datatype in varchar2 default data_type_text,
    p_in_out_attr_varray in out nocopy wwsrc_runtime_attr_varray
    My question is : where is the type wsrc_runtime_attr_varray ?
    any clues ?

    hi sebastien,
    I've some troubles when performing a search using the "specify_attributes" procedure
    I get the SEARCH_FAILURE_EXCEPTION when i try to search items with an attribute.
    The search works well without calling it.
    Can you help me ?
    CODE
    create or replace
    PACKAGE BODY PKG_SEARCH AS
    PROCEDURE get_contents(p_siteid INTEGER, p_intitule VARCHAR2 DEFAULT NULL) IS
    v_result portal.wwsrc_api.items_result_array_type;
    v_outcount NUMBER;
    v_outscores portal.wwsrc_api.number_list_type;
    v_attributes portal.wwsrc_runtime_attr_varray;
    v_intitule portal.wwsbr_item_attributes.VALUE %TYPE;
    -- Attribut "INTITULE"
    v_intitule_attrid NUMBER;
    v_intitule_caid NUMBER;
    v_intitule_type VARCHAR2(20);
    BEGIN
    * Construction de l'objet ATTRIBUT avec la vue WWSBR_ATTRIBUTES
    * partie "INTITULE"
    select id, caid, data_type into v_intitule_attrid, v_intitule_caid, v_intitule_type
    from portal.wwsbr_attributes where name = 'INTITULE' and rownum = 1;
    portal.wwsrc_api.specify_attributes(
    p_id => v_intitule_attrid,
    p_siteid => v_intitule_caid,
    p_value => p_intitule,
    p_operator => portal.wwsrc_api.MATCH_ANY,
    p_datatype => v_intitule_type,
    p_in_out_attr_varray => v_attributes
    v_result := portal.wwsrc_api.item_search(
    p_attributes => v_attributes,
    p_attributesmatch => portal.wwsrc_api.match_any,
    p_out_count => v_outcount,
    p_out_scores => v_outscores);
    -- nbre de résultats
    htp.prn('Total : ' || v_outcount);
         -- pour chaque resultat
    FOR i IN 0 .. v_result.COUNT LOOP
    IF v_result.EXISTS(i) THEN
    -- récupération de l'attribut personnalisé 'INTITULE'
    SELECT VALUE INTO v_intitule FROM portal.wwsbr_item_attributes
    WHERE item_caid = p_siteid AND item_masterid = v_result(i).id
    AND attribute_id = v_intitule_attrid AND attribute_caid = v_intitule_caid;
    -- PRINT
    htp.prn('<document>');
    htp.prn('<id>' || v_result(i).id || '</id>');
    htp.prn('<type><![CDATA[' || v_type || ']]></type>');
    htp.prn('</document>');
    END IF;
    END LOOP;
    htp.prn('</documents>');
    -- gestion des exceptions
    EXCEPTION
    WHEN portal.wwsrc_api.search_failure_exception THEN
    htp.prn(' An internal exception was raised by
    * Portal or Oracle Text');
    WHEN others THEN
    htp.prn('Erreur inconnue');
    END;
    END PKG_SEARCH;

  • Setting default value of document library column using powershell

    Created document library based on template which is using custom content type containing managed metadata based column.
    I can upload documents. Everything looks normal except when I visit Column default value settings page in DL settings, I get error message below
    Application error when access /_layouts/15/ColumnDefaults.aspx, Error=Value does not fall within the expected range.   at Microsoft.SharePoint.SPWeb.GetWebRelativeUrlFromUrl(String strUrl, Boolean includeQueryString, Boolean canonicalizeUrl)    
    at Microsoft.Office.Server.WebControls.MetaDataNavTree.TreeViewDataBound(Object sender, EventArgs e)     at System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect()     at Microsoft.Office.DocumentManagement.MetadataNavigation.MetadataNavigationContext.OnTreeViewLoad(SPTreeView
    spTreeView)     at Microsoft.Office.Server.WebControls.MetaDataNavTree.PerLocationPageLoad()     at Microsoft.Office.DocumentManagement.Pages.ColumnDefaultsPage.OnLoad(EventArgs e)     at System.Web.UI.Control.LoadRecursive()
        at System.Web.UI.Page.ProcessRe...  6bf73b9c-e4f3-10ae-0f74-9672cdd9936f
    I tried many things but nothing seems to work. When I create document library using SharePoint OOB template, everything works.
    Any help would be appreciated.
    Thanks.

    I found another way to fix this. Thanks to you pointing me to the file "{List Name}/Forms/client_LocationBasedDefaults.html"
    I found the difference between this file and the one of a list that worked:
    I had "&" in the names of some folders. The recreated subsites from a template that contained such folders in the document library had the problem descriped by the OP. In the recreated client_LocationBasedDefaults.html there were actual '&'
    in the folder names instead of '%26' escape characters. After replacing those characters with their escaped version everything worked as expected again.

  • Is there a way to run IDS within Websphere to recieve messages through JMS, then invoke Documaker?  Configuring the IDS client to use JMS within websphere seems pretty straight forward, but I cannot find information on running IDS as a server to invoke Do

    Looking to move the maintenance of our IDS instances which drive Documaker MRLs from the Unix command line to within a container ( Websphere ).  Using the IDS Java client with JMS is pretty easy.  I cannot see how I would be able to get an IDS server running within Websphere.

    IDS is not designed to run in WebSphere or any other J2EE container. It is a standalone Java application that uses native code, allows to run custom code, reads and writes files on disk, starts other processes, etc. and as such is not exactly suitable to run in J2EE. Most of such actions are not enabled (at least by default) in J2EE due to security concerns. You could run it as a service on Windows or setup to start automatically on Unix.
    What exactly do you want to achieve by it being in J2EE container? Perhaps there are other ways to do the same thing?

Maybe you are looking for

  • No longer able to view NEF files in Bridge or edit in Camera Raw 4.6

    I have found similar questions in various Adobe forums, but I have not located a solution to my problem. Bridge CS3 Photoshop CS3 Extended XP Camera Raw version 4.6.0.30 Nikon D300s Up until 2 weeks ago I have been copying my NEF files from my CF car

  • Java Print Service API in Java Stored Procedure (Linux)

    Hi We are running an Oracle 10g database on Linux and I am in the proces of developing a java stored procedure which should utilize the Java Print Service API. I have made a simple stored procedure to list all available printers and the DocFlavors th

  • How to update values for qty n batch in mska table

    Hi experts, i would lke to know is it possible that we can update value of availabity of stock which is existing batch wise in MSKA table field 'kalab' (qty) n charg (batch). i mean we have devided material per document number into batch a b c. supos

  • Extracting individual drivers from BC 2.1  update ?

    I am trying to sync a Windows PDA (Vista OS w/Parallels),,and don't want to do a total update for fear of getting problems that many of you are having trouble with.So, I am wondering whether I for example,get the bluetooth drivers (or any other separ

  • IDVD replacement

    I've happily used iDVD until I just got a new iMac - with no iDVD.  Anyone using a replacement they can suggest?