0

Experts ,The name of the uploaded file is eg: MEA-EU.xlsx (Refer the 2nd picture below). I want to extract the name of the file to another 2 column name (GM and DSC).

For example MEA will be under GM Column, while EU will be under DSC column I knew the function of calculated column , but there isn't name of the file to refer(Picture drop down below). So what are the solution? Do I need to use sharepoint designer and if yes how? Or if use calculated how? or there is any other thing that I can do. please help! Thanks in advance

the refer column

eg: MEA into GM and EU into DSC

  • Are you using SharePoint online orSharePoint 2013 (or any version of onpremise)? – sssreddy Sep 25 '18 at 17:27
  • sharepoint online and sharepoint designer 2013 sir – Muhammad Hazrin Sep 26 '18 at 2:19
0

If you are on the on-prems server, you can write an event receiver to copy the values from one field to another.

See the answer in this post

First, in case you need to run your event receive on a specific List, so you should modify Elements.xml to use ListUrl instead of ListTemplateId as the following
<Receivers ListTemplateId="101">

to
<Receivers ListUrl="Lists/test">

Where the Lists/test is the List URL


Second, try to use the below code to 
public override void ItemAdded(SPItemEventProperties properties)  
{ 
   base.ItemAdded(properties);  
    using (SPWeb web = properties.OpenWeb())  
    {  
        try  
        {  
            // get the current List item            
            SPListItem currentItem = properties.ListItem; 
            // Second list
            web.AllowUnsafeUpdates = true;
            SPList List2 = web.Lists.TryGetList("destlist");
            SPListItem newItem = List2.Items.GetItemById(ID);
            newItem["FieldName"] = currentItem["FieldName"];
            newItem.Update();  
        }  
        catch (Exception ex)  
        {  
            throw ex;  
        }  
    } 
}


Note: in case you don't know the corresponsind item ID, you can get theList item via CAML at SPQuery, check the details at another thread at How to check if list item already exists? C# Sharepoint 2013

If you are using SP Online, you can try field formatting. Do a google search on this one.

0

You cannot use a calculated column with the name column. You can build a designer workflow that runs on item creation and update the columns with data extracted from file name.

Alternatively, as you seem to be using SharePoint online you can also build a Microsoft flow to do the same.

enter image description here

To extract the first part I used the expression

substring(triggerBody()?['{Name}'], 0, lastIndexOf(triggerBody()?['{Name}'],'-'))

For the second part I used an expression

substring(triggerBody()?['{Name}'], add(lastIndexOf(triggerBody()?['{Name}'],'-'),1), sub(sub(length(triggerBody()?['{Name}']),lastIndexOf(triggerBody()?['{Name}'],'-')),1))
  • sir , I copy paste ur expression into the 2 columns, but instead it pops up " invalid expression". @sssreddy – Muhammad Hazrin Sep 26 '18 at 2:26
  • There was a typo in expression. See updated answer. – sssreddy Sep 26 '18 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.