Checks if item field link exists into a custom list

Hi;
I have a custom list with 2 columns : Title and SITE (field link)
Title (text) : 
SITE (link) :   URL + DESCRIPTION
I would like to write in programmming a code which allows to checks before to add a new item if this item exists or not into the list in using only the DESCRIPTION or URL field.
Like this :
if(DESCRIPTION !exists)
{   add item }
else{ show message : the site exists }
Regards 

Hi,
We can use event receiver to achieve your requirement. The following code for your reference:
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace SharePointProject5.EventReceiver1
/// <summary>
/// List Item Events
/// </summary>
public class EventReceiver1 : SPItemEventReceiver
/// <summary>
/// An item is being added.
/// </summary>
public override void ItemAdding(SPItemEventProperties properties)
base.ItemAdding(properties);
if(properties.AfterProperties["SITE"]!=null)
string linkField=properties.AfterProperties["SITE"].ToString();
string urlValue = linkField.Split(',')[0];
if (CheckItemExists(properties.List, null, urlValue))
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = "The site exists.";
private bool CheckItemExists(SPList list, SPFolder folder, string urlValue)
SPQuery query = new SPQuery();
if (folder != null)
query.Folder = folder;
query.Query = @"
<Where>
<Eq>
<FieldRef Name='SITE' />
<Value Type='Text'>" + urlValue + @"</Value>
</Eq>
</Where>";
SPListItemCollection found = list.GetItems(query);
return (found.Count > 0);
Best Regards
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]

Similar Messages

  • How to check if a file (picture) exists into a war?

    Hello, I have made a Java/J2EE project using countries in the world and I have at my disposition a folder of flags icons.
    Some countries don't have any flag icon for any reason and in my application, I'll be able to add new ones.
    In my code, I want to do display the flag of the current country if available else display a default icon.
    Here is what I am currently doing:
    String contextPath = facesContext.getExternalContext().getRequestContextPath();
    String flagUrl = contextPath + "/images/flags/"+ name.trim().toLowerCase() + ".png";
    boolean exists = (new File(flagUrl)).exists();The issue is exists is always set to true no matter the existence of the flag.
    Here is what my variable nammed flagUrl looks like : /images/flags/ca.png
    How do you check the existence of a file into a war? Thank you
    Edited by: cotede3 on Mar 11, 2010 5:32 AM

    Unfortunately I cannot call getRealPath on application.
    application in my code is :
    BBrApplication application = null;
              // Searchs entity class icon
              FacesContext facesContext = FacesContext.getCurrentInstance();
              if (facesContext != null)
                   application = BBrApplication.getInstance(facesContext);So I tried
    String realFilePath = application.getContextRoot();but I end up with
    realFilePath = /DFP/.
    so It is not the absolute path displayed...
    How can I do ?

  • ABAP-command to check wheather a field in existing in a spec.table/structur

    Hello together,
    we have a tool to do corrections to CO-PA-transaction data.
    Because we have different structures for different operating concerns (and therefore different dynpros for those different operating concerns) we now want to dynamize this tool.
    The idea is to have one dynpro with the maximum number of CO-PA-fields and to control via a functional-module which vields are existing for one operating concern and those are not existing for that operating concern to change the attributes to non-changeable.
    Is there any command in ABAP to check if one field (e.g. one valuefield) is contained in one table-structure (e.g. table-structure CE1xxxx) ?
    Kind regards
    Udo

    *--Verfy infoobject exit or not
      call function 'DDIF_FIELDINFO_GET'
        exporting
          tabname        = KNA1   <--here you pass structure
        tables
          DFIES_TAB = <itab>    <--get list of fields in the table
        exceptions
          not_found      = 1
          internal_error = 2
          others         = 3.
      if sy-subrc <> 0.
        message  text-005 type 'E' .
      endif.
    loop at  <itab> assigning <field>.
    *here you validate wether field is available in the structure or not
    assign component 'SIGNCH'  of structure <field> to <f_sign>.
      if sy-subrc ne 0.
        message  'SIGNCH field is not available in table KNA1'  type  'E' .
      endif.
    endloop.
    Regards,
    Peranandam

  • Cannot remove description field after adding to the Custom List

    Hello,
    Applies To: SharePoint 2013
    Problem: We created a Custom List and added a Description column from "Add from existing site columns" link. Now we need to remove it and it seems to have been sealed. We are not able to delete it.
    There is no remove/delete link/button when we click on the field. Moreover in the Content Type it only shows Required, Optional, Hidden.
    Requirement: Need to remove this field from the Custom List. Incidentally we added two of the description fields. We need to remove both of them without deleting the list itself.
    Thank you and
    Regards
    Tanzim Akhtar
    Tanzim Akhtar

    Hi Tanzim,
    Try the following code. I tested it and it should work for you.
    Add-PSSnapIn Microsoft.SharePoint.Powershell
    $web = Get-SPWeb "Web URL" 
    $list = $web.Lists["List Name"] 
    $field = $list.Fields["Description"] 
    $field.AllowDeletion = $true
    $field.Sealed = $false
    $field.Delete() 
    $list.Update() 
    Remove-PSSnapIn Microsoft.SharePoint.Powershell
    Narahari
    ******If a post answers/helps your question, please click "Mark
    As Answer" on that post and/or "Vote
    as Helpful*******

  • Created By and Created Date fields not showing up on Custom List form webpart

    Hi,
    I have added Custom Listform WebPart on "DispForm.aspx" of custom list. I need to display, out of box fields "Author" [Created By] and "Created" [Creation Date] on this custom list form webpart, I have added them on the webpart, following is the code behind of aspx page:
    <td width ="400px" valign= "top" class="ms-formbody">
    <xsl: value-of select = "@Author" disable-output-escaping = "yes"/>
    </td>
    However these fields are not showing/populating data on the form ?? Any inputs ???
    Regards

    Hi,
    I think that when you insert a custom list form web part you select “Item” content type, so custom list form is designed to display only the fields that are appropriate for that content type “Item”, but the item content type doesn’t contain the created and created by column, when you add the two columns, it will not find the field value. By default, the two columns will display at the foot of the list form using SharePoint:CreatedModifiedInfo.
    Hope it can help you.
    Xue-Mei Chang

  • Rename title column and delete a column into view custom list

    Hi;
    I try to create a new custom list with only 2 column DEC et DSCC and I would like to rename or change the title column (Titre in french) with the name "DEC" and next hide or delete into the view "All elements" the column attached file ("Pièces
    jointes" in french).
    My code is :
    function CreateCustomList
      param(
      [string]$web
    $spWeb = Get-SPWeb -Identity $web
    $list=$spWeb.Lists.TryGetList($listeEspaceRTO)
    if($list -eq $null)
     $spTemplate = $spWeb.ListTemplates["Liste personnalisée"]
     $spListCollection=$spWeb.Lists
     $spListCollection.Add($listeEspaceRTO,"Liste espace RTO",$spTemplate)
     $path = $spWeb.url.trim()
     $spList = $spWeb.GetList("$path/Lists/$listeEspaceRTO")
     $spList.Fields.Add("DSCC","URL",$false)
     $Views = $spList.Views["Tous les éléments"]
     //$Views.ViewFields.delete("Pièces jointes")
     //$Views.ViewFields.Add("DEC")
     $Views.ViewFields.Add("DSCC")
     $Views.Update()
    else
      write-host -f yellow "la doc lib" $listeEspaceRTO "exits"
    $spWeb.dispose()
    The custom list is correctly created but with Title and the column "Pièces jointes" into the view.
    Regards

    Hi,
    Glad to hear that you solve this issue, thanks for your sharing.
    Thanks,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to link Discussion Board with Custom list in sharepoint 2013

    I have a custom list, which  have collection of goals. and i have an discussion board for discussions about those goals from that custom
    list... so how can i link between those two. what my expectation is, if I select a "goal" from custom list, then the collection of discussions that related to goals will displays on other side...  and i have added a lookup column in discussion
    board that refer the goal name in the custom list so i am relating goal name between these two. 

    Hi VinoJash,
    According to your description, my understanding is that you want to click the ‘discuss’ column in the custom list to navigate to the associated discusstion. Is it right?
    You can do as the followings:
    Open your custom list
    Create a new column, the type is Hyperlink or Picture, select Format URL as: Hyperlink
    Navigation to a discussion, copy the URL of the discussion
    Back to the custom list, and new an item
    Type the title, and paste the URL copied in step 3 under ‘Type the web address:’, type a name for the description of the url
    Click Save
    In my testing, the result is :
    If I click ‘first discussion’, it will open the ‘first’ discussion.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • VALIDATE ITEM MESSAGE IF EXIST INTO TABLE

    I have a problem ...
    Digit in a text ITEM to be validated in a table EXIST there should generate error. And do not let go until it is fixed .. as I do?
    I found a plugin but it does not work correctly.

    Okay. Validations are server-side, meaning that they fire on submit. The database does the checking. You want something client-side, which means you're going to have to do it in JavaScript or maybe in a dynamic action.
    <script language="JavaScript" type="text/javascript">
    function check_hours(pThis){
      if(pThis.value > 13){
        alert("Please double-check hours");
      return true;
    </script>Put this in the HTML Form Elements Attributes of your page item:
    onchange="check_hours(this)"This is a simple example, but may help get you started. In this case, I am using an Alert box because the value may be correct. This example is meant as a warning, not necessarily as a "do-not-pass-go-do-not-collect-$200" type of prohibition.

  • How to link existing PG with custom VO at design time

    Hi,
    I want to customzie counter group seach page of Counters modules. Here instead of searching thorugh apps schema i want to search groups through my custom schema 'XYZ'. To achieve this, i did following task:
    (i) exported GroupSearchPG from apps server to jdeveloper/myprojects directory.
    (ii) Created workspace and project in jdeveloper and imported PG to this project.
    (ii) downloaded GroupingSearchAM , GroupSearchVO and GroupSearchCO from $JAVA_TOP to Jdev myclasses directory, its working fine for apps schema from jdeveloper
    (iii) Created BC4J package with existing name oracle.apps.csi.counter.grouping.schema
    (iv) created custom VO (GroupSearchVO) with custom schema 'XYZ' (Since this is expert VO, I need not to extend base EO/VO)
    Now, While trying to substitute my custom VO with existing VO. I could not see existing VO to replace with.
    My question is how do we link components with exported page? I mean how does the linking happens with GroupSearchPG with its CO/EO/VO or AM.
    Can you please let me know which step did i miss?
    Thanks in advance
    Tripti

    For your situation,
    VO needs to be substituted,
    CO needs to be substituted and
    AM needs to be extended.
    To make your custom VO available in substitution process, add them to the extended AM. Custom CO can be attached through personalization.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Linking a library to a list - filtering data per selected drop down / check box item

    Good day,
    I am rather new to SharePoint and have run into a dilemma. Is it possible to link a library to a list, then create a parent-child relationship between the the department (list) to document (library)? 
    Example - I have a library that contains 100+ documents, the library is filtered using groups/subgroups. 
    IT
     -> IT TX (30 docs)
     -> IT WI (10 docs)
    Biz Ops 
     -> Biz Ops WI (8 docs)
     -> Biz Ops CA (5 docs)
    In the list I created I have departments as a required field, and a dropdown tool that shows the 5 departments that contain items that need to be grouped together. (Biz Ops, IT, HR, Sales, and Compliance)
    I have linked the library of documents to the form (list), using "Lookup (information already on this site)". All the documents in the library appear in the selection box within the list. However is it possible to first select a department which
    then filters documents only tied to said department? So at the beginning of the list you choose the department you wish to browse the documents, then it filters out all documents not related to that department? 
    My apologies if this is long winded and confusing. Your help is most appreciative. 
    Cheers. 

    Hi,
    According to your post, my understanding is that you wanted to filter the corresponding documents from a Document Library when you selected a department in a List.
    I recommend that you can follow the steps as below to implement it in your environment.
    1. Create a new Web Part Page and add the Document Library and the List web part into it.
    2. Click the List web part, click the current web part’s drop-down arrow, choose Connections, Send Row of Data To, and then choose the Document Library web part.
    3. Click the Document Library web part, choose the “All Items” view from the Selected View, click the current web part’s drop-down arrow, choose Connections, Get Filter Values From,
    and then choose the List web part.
    4. Open the Configure Connection – Webpage Dialog, choose the “Department” column from the Provider Field Name drop-down list and choose the “Group” column from the Consumer Field
    Name drop-down list.
    5. Click Apply, OK button, save the Web Part Page and test it in your environment.
    For more information, you can refer to:
    http://office.microsoft.com/en-us/sharepoint-server-help/connect-data-in-web-parts-HA101785157.aspx
    http://www.dummies.com/how-to/content/connect-web-parts-in-sharepoint-2010.html
    Best Regards,
    Linda Li
    TechNet Community Support

  • Link Reports -item  does not exists on this page

    I have two tables Person table with Primary Key of PersonID, and Person_Qualification Table with a FK of Person_ID.
    I have a report for each table. I have created a report on the Person Table(Page 3000) with a link column to the Person Qualification Report (Page 3119).
    In the link column I created in the person report I have my parameters set as P3000_PersonID and #Person_ID# as field to populate the URL with, and the target page as 3119.
    However anytime I click this link that takes me to the PersonQualification report I get an error stating the Item P3000_Person ID does not exists on this page (3119).
    I have linked a form and report together before, but not two reports.
    I want the person qualification report to be only for the personID that was clicked on.
    I tried adding P3000_PersonID to the query in the person_qualification page I.E. where PersonID=:P3000_PersonID but I still get the item P3000_Person ID does not exists on this page or something to this effect.
    Thanks

    Hello gtjr,
    You need to define an item (usually hidden) on page 3119 to hold the person ID and use that in your second report's query.
    Then in the column link for the first report, specify this new item to be set to the person ID linked.
    The reason for the error is you're telling ApEx to set an item p3000_person_id on page 3119, but that item doesn't exist on page 3119.
    Hope this helps,
    John
    Please remember to reward helpful or correct responses. :-)

  • Free item field checked defaultly in PO for one specific vendor

    Hi,
    If we always send a free PO to a vendor, is there any place to configure that once we create PO to this specific vendor, the free item field is checked defaultly?
    Some posts on the web indicated that they succeeded in doing this by setting in vendor master, but I cannot find the field.
    Where to achieve this function?
    Thanks!
    Wesley

    Hi,
    try to maintain a free goods condition in tcode MBN1 with        
    Discount type NR00 and make this article as an Additional material free    
    goods which will be procured free of cost on purchase of some other        
    article. The system will not consider the Net price value maintained in    
    the purchasing view of the article master and you would find that the      
    net price is ZERO for this free item in the Purchase order. 
    Regards,
    Edit

  • ME51N - need to concatenate the PR # & the item # into a custom field.

    Hi All,
    I need to concatenate the PR number and the item number into a custom field in the customer data tab in transaction ME51N. I been looking at some user exits, but the problem is that when I try to use BAPI_PR_CHANGE in a user exit the BAPI failed, because the PR has not been committed to the EBAN table and it cannot fined it. The custom field is in the EBAN table. The other problem is that most user exits don't have access to the PR number. Can anyone tell me how I can update the custom field on a new PR creation after I click the save button?

    Hi All,
    I need to concatenate the PR number and the item number into a custom field in the customer data tab in transaction ME51N. I been looking at some user exits, but the problem is that when I try to use BAPI_PR_CHANGE in a user exit the BAPI failed, because the PR has not been committed to the EBAN table and it cannot fined it. The custom field is in the EBAN table. The other problem is that most user exits don't have access to the PR number. Can anyone tell me how I can update the custom field on a new PR creation after I click the save button?

  • SAP Cloud SDK : Default Check in Marketing Lead for Field "Use Existing Account"

    Hi Experts,
    I have requirement to enhance the standard business object Marketing Lead screen. In that screen i need to make default check on "Use Existing Account" checkbox when user click on New Marketing Lead or QC option.
    I have tried using Application studio but the field "Use Existing Account" not exist in cloud repository its on Front-end UI screen.
    How i can make default value check to this checkbox in UI designer for standard screen
    Or
    How i can make default value check to this checkbox using ABSL code.
    Please refer the screen as shown below.
    Regards,
    Mithun

    Mithun,
    Could you please check Fine tune options available for Leads ?
    Under Involved Parties there is an option "Forbid Manual Changes". For Account Party Role if you select that it will not allow user to enter new account information.
    Fine -Tune -> Leads - > Involved Parties -> Account
    - Shrikant

  • How do  we check the check box items based on the databse fields.

    Hi All,
    I have a requirement like as mentioned below#
    1. I have a combox box whcih i will be populated from database.
    2. I have created two check box as "Stategric " and "Non Stategric".
    3. Now when i select the combox box condition i need to select the check box items.
    4. But the problem is i wil be knowing weather it is a stategric or Non stategirc based on the database column.
    5. How do i need to map the database point of view and correlacte with javascript pont of view.
    6. Do we need to write any Application process to achieve this task and who we can do that.
    Thanks,
    Anoo..

    Hi VC,
    As per my understanding the code should be placed between --.
    Based on this i have placed the code
    function setCheckbox(pThis, pItem){
    alert('inside');
        var l_code = '';
        // Get checkbox name
        rName = document.getElementsById('P1_ENG_BAU').firstChild.name;
    alert("The value is"+rName);
        // Fire AJAX
        var get = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=CHECKBOX_LIST',0);
        get.add('F120_COMPANY',pThis.value);
        gReturn = get.get('XML');
        if (gReturn) {
          var values = gReturn.getElementsByTagName('value');
          var messages = gReturn.getElementsByTagName('message');
          // Build the checkbox
          for (i=0; i<values.length; i++) {
            var rValue = values.firstChild.nodeValue;
    var rMessage = messages[i].firstChild.nodeValue;
    l_code+='<input id='+P1_ENG_BAU+'_'+i+' type=checkbox value='+rValue+' name='+rName+'>';
    l_code+='<label for='+P1_ENG_BAU+'_'+i+'>'+rMessage+'</label>
    document.getElementsById('P1_ENG_BAU').innerHTML = l_code;
    Correct me if iam understanding is wrong.
    Thanks,
    Anoo..
    Edited by: Anoo on May 31, 2012 11:04 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Can't update or access itunes

    I received an upgrade notification and told it to download and install, but I didn't reboot my machine until later. When it came back up, and I tried to open itunes, this error popped up - "This action is only valid for products that are installed."

  • How to connect hdmi

    I have a MacBook Pro and a HDMI cable which once did work, but no longer. Did  software change, did my luck run out?  What can I do to make HDMI cable work again?

  • HELP Mail has stopped working

    On my G3 Tower, my mail account has stopped working. It says it can't communicate with the host. But, I haven't changed anything about my wireless network and my browsers are working just fine. I also have a G4 laptop and all is fine with the mail fu

  • CRM 2011: Logo

    Someone in our company who is no longer with us changed the loge in crm to XRM. We need to change this how or where do I go to change this? Also, if you have different companies, can they all be different to that specific company? Thanks, Wendy

  • FM for conversion of unit!!

    Hi, I need to convert the qunatity field from one unit to another.... from kg to gram.... which func mod is best suited... Regards Gunjan