Create a list with associated workflow from a list template.

Hi,
I have a calendar list with two workflows and I saved it as list template. Also I have an event receiver which creates a list based in this list template I created, but I noticed that the list is created without workflows. If I create the list
using the list template using SharePoint it does it with the workflows but my event receiver does not.
Here is my code:
if
(list == null){
web.AllowUnsafeUpdates =
true;
var lstTemp = web.Site.GetCustomListTemplates(web);
var template = lstTemp[listTemplate];
var listId = web.Lists.Add(listName,
string.Empty, template);
list = web.Lists[listId];
list.Title = listName;
list.OnQuickLaunch =
false;
list.Update();
web.AllowUnsafeUpdates =
false;
Thanks anyway.

Hi,
According to my understanding, you have a list template contains workflow, you can create a new list with this template from UI. However, when create a list with this
template in Event Receiver, the workflow is missing.
I tried to reproduce by creating a list template contains an OOTB Approval workflow, then use an Event Receiver to create a list with this template, it turned out
that the workflow is attached to the newly created list.
I would suggest that you create another Event Receiver with the code snippet below to see if it is an issue of Event Receiver:
public override void ItemAdded(SPItemEventProperties properties)
base.ItemAdded(properties);
createListWithTemplateWithWF(properties);
public static void createListWithTemplateWithWF(SPItemEventProperties properties)
using (SPSite site = properties.Site)
using (SPWeb web = site.RootWeb)
SPListTemplateCollection listTemplates = site.GetCustomListTemplates(web);
SPListTemplate listTemplate = listTemplates["ListTemplate_List001_withWF"];
web.Lists.Add("List005", "List005", listTemplate);
Feel free to reply with the test result or if there any questions about this.
Best regards,
Patrick
Patrick Liang
TechNet Community Support

Similar Messages

  • HANA XSODATA Create multiple entities with associations in single LUW

    Hi all,
    Is it possible to create multiple entities with associations in a single LUW.
    For e.g. we have a Sales Order and Item. This is modelled as 2 DB tables and 2 entities.
    In XSOData I have defined association relationship between them.My XSOData definition is like this...
    "XSDemo.DB::SO"    as "SalesOrder"
       navigates ("SalesOrder_OrderItem" as "SOItem");
       "XSDemo.DB::ITEM" as "OrderItem";
       association "SalesOrder_OrderItem" principal "SalesOrder"("OrderID") multiplicity "1"
       dependent "OrderItem"("OrderID") multiplicity "*";
    My post URI is
    http://server:port/SODemo.xsodata/SalesOrder
    My data is as follows
      "ID": 1,
      "Customer": 123,
      "Desc": "Test SO",
      "SOItem": [
          "Material": "MAT1",
          "Qty": "10",
          "Item": "10"
          "Material": "MAT2",
          "Qty": "20",
          "Item": "5"
    From the post, I get a response 201 (Created). However, only the Sales Order is created. The Items are not created.
    My question is:
    1. Is it possible to create Order and Item together in a single post call ?? If yes, how. What is the syntax of XSOData / Post Request
    2. If it is not possible to create Order and Item together in a single post call, then how do we ensure atomicity of the transaction.
    For e.g. What is Order creation is success and then the Item creation fails ...
    How can we ensure that all is committed or none is committed.
    3. From the documentation I understand that this might be possible using modification exits... However, I want to achieve this without using modification exits...
    Is this possible or not ?

    Hi Thomas,
    Actually the problem is that Sales Order and Order Items are modeled as different entities... So, XSOData allows creation of Sales Order Item independently WITHOUT creation of a sales order header.
    For e.g. URL : http://server:port/SODemo.xsodata/OrderItem
    Ideally, the XSOData should implement a logic that a Dependent entity cannot be created without a Principal entity.
    For e.g. using a Sales order BAPI you cannot create a sales order item alone !
    Similarily, since XSOData is the end point service for the consumer, the XSOData should have the logic to ensure that both principal and dependent entities are created together.
    Otherwise, in the UI the developer has to ensure that the post body is build correctly...

  • How to export All computer list with operating system from AD and all attributes like disable or enable and OU location also?

    how to export All computer list with operating system from AD and all attributes like disable or enable and OU location also?
    I have tried with dsquery below but status is not showing there.
    dsquery * -filter "(objectCategory=computer)" -attr name operatingSystem

    last logon user name - not really stored (or lined) with computer object.  However, you can get this info during the logon process or from the computer.  Here is method:
    http://portal.sivarajan.com/2010/07/user-profile-and-os-info-powershell.html
    Santhosh Sivarajan | Houston, TX | www.sivarajan.com
    ITIL,MCITP,MCTS,MCSE (W2K3/W2K/NT4),MCSA(W2K3/W2K/MSG),Network+,CCNA
    Windows Server 2012 Book - Migrating from 2008 to Windows Server 2012
    Blogs: Blogs
    Twitter: Twitter
    LinkedIn: LinkedIn
    Facebook: Facebook
    Microsoft Virtual Academy:
    Microsoft Virtual Academy
    This posting is provided AS IS with no warranties, and confers no rights.

  • How do I combine my iphone contact list with my laptop pc contact list?  And how does it handle duplicates with different information?

    How do I combine my iphone contact list with my laptop pc contact list? And how does it handle duplicates that have different information?
    How do I merge my iphone calendar appointments/alerts with my laptop pc calendar appointments/alerts?  And how does it handle duplicates?
    I do not need anything to change on my email that is working fine on both.

        gspielman,
    Help has arrived to assist you with getting those contacts on both your devices. The Verizon cloud service is definitely a great tool to use and you can also use Apple iCloud as well. When you sign into the Verizon cloud on your iPad does it give an option or message to restore?
    CandiceH_VZW
    Follow us on Twitter @VZWSupport

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • How do I create a series of text frames from a list of files?

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

    And I'm back again.
    This time, I'm wondering how I can use JavaScript to place a series of text frames from a list of files, preferably with the ability to specify criteria before running the script.
    Here's the details: I work for a newspaper and I lay out stories for the pages (in addition to the other part of my job, laying out ad spaces, as detailed in a previous thread, for which I requested another script, thanks Andreas and Jongware ). The file names for the stories are labeled for the section they go in, like L- for Life, C- for Comment, S- for Sports, etc.
    I'd like to create a script that asks for a criteria in a text box (where I can type L-, C-, S- or whatever else I need) and then places all of the stories, in a specified directory, whose file names match what was typed in the box, one text frame for each.
    I can't rightly tell if this is a simpler or more difficult script to write out, but I plan on putting research into it as usual so I can develop it myself. However, I figured it would be more efficient to ask first, then research, so that while I'm researching, I can refer to the opinions of my fellow forumites, and/or the mods.
    Thanks again for any assistance offered.

  • How do I create a list which compiles data from all lists on the sharepoint?

    I have many pages to my sharepoint which all have separate task lists. On my overview page I want to create a list so that all the tasks and data inputted into the other task lists on the site are compiled together in one list. This way I have a long list
    of tasks in one place, without going to each list. How would I do this?
    Thanks!

    Hi,
    Based on your description, my understanding is that you want to collect all the task items on a site to one task list.
    For accomplishing your request, you can create a Reusable Workflow.
    Open your site with SharePoint Designer 2013->create a Reusable Workflow named task, choose 2010 platform and Task content type->choose Copy List Item Action->Copy current item to you target task list.
    Then in every task list, create a workflow based on the new reusable workflow.
    Besides, you can use Project Summary web part or Content Search web part to accomplish collecting all task items.
    If there still exist some problems, Please feel free to let me know.
    Best Regards,
    Lisa Chen

  • List with user data from User Profile Service

    Hi there!
    I got SP intranet site up and running with more then 2000+ users on it.
    User Profile Services is getting users attributes from Active Directory.
    How can i make a list with all of those users and columns like Department, Manager, Office number, etc.. 
    After that i'm going to apply a filter by current user department.
    I would really appreciate some offer.
    Thanks!

    There is a sharepoint hidden list called User Information List , if you want to filter by current user department I recommend that you use ser search API and search People using SourceID 
    public static ResultTable SearchUsers(string query,int limit,string [] selectproperties)
    KeywordQuery kq = new KeywordQuery(SPContext.Current.Site);
    //select properties
    foreach (string property in selectproperties)
    kq.SelectProperties.Add(property);
    kq.SourceId = new Guid("B09A7990-05EA-4AF9-81EF-EDFAB16C4E31");
    kq.QueryText = query;
    kq.RowLimit = limit;
    ResultTableCollection results = new SearchExecutor().ExecuteQuery(kq);
    return results.Filter("TableType", KnownTableTypes.RelevantResults).FirstOrDefault<ResultTable>();
    you need to pass the query Department:CurrentUserDepartment and to get current user department 
    UserProfileManager manager = new UserProfileManager(SPServiceContext.GetContext(SPContext.Current.Site));
    UserProfile currentUser = manager.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);
    string department=currentUser["Department"].toString();
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • Delete batches with zero stock from dropdown list

    Hi All,
    I have a requirement on batch stock materials.The exist program displaying multiple batches for material plant with stock and without stock in the drop down list for MCH1 table in the pop up window.
    Now i would need to delete the batches with zero stock from drop down list.I could find the data for stock and non stock from MCHB table .
    Any idea how to delete the entry of non stock batches from drop down list
    Regards,
    Reddy

    Hi All,
    The logic has already been implemented to for drop down list for all batches(with or without stock) for material plant.the follwing code has been written for the same.
    Any idea how to delete the entry for non stck baches from the drop down list.
    this is the code
      SET PARAMETER ID 'MAT' FIELD help_lips-matnr.
       SET PARAMETER ID 'WRK' FIELD help_lips-werks.
      Export parameters to memory to enable search help via classes
       CLEAR dseltab.
       REFRESH dseltab.
       dseltab-fldname = 'MANDT'.
       MOVE sy-mandt TO dseltab-fldinh.
       APPEND dseltab.
       dseltab-fldname = 'MATNR'.
       MOVE help_lips-matnr TO dseltab-fldinh.
       APPEND dseltab.
       dseltab-fldname = 'WERKS'.
       MOVE help_lips-werks TO dseltab-fldinh.
       APPEND dseltab.
       dseltab-fldname = 'CHARG'.
       MOVE help_lips-charg TO dseltab-fldinh.
       APPEND dseltab.
       EXPORT dseltab TO MEMORY ID 'DSELTAB'.
      Get description for search help
       mc_object = 'MCH1'.
       lf_shlpname = mc_object.
       CALL FUNCTION 'F4IF_GET_SHLP_DESCR'
         EXPORTING
           shlpname = lf_shlpname
           shlptype = 'SH'
         IMPORTING
           shlp     = lx_shlp
         EXCEPTIONS
           OTHERS   = 1.
      Enable value copy from search help to dynpro field
       READ TABLE lx_shlp-interface INTO ls_interface
                                    WITH KEY shlpfield = 'CHARG'.
       ls_interface-valfield = 'X'.
       MODIFY lx_shlp-interface FROM ls_interface INDEX sy-tabix.
      Start search help dialog
       CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
         EXPORTING
           shlp          = lx_shlp
         TABLES
           return_values = lt_retvalues
         EXCEPTIONS
           OTHERS        = 1.
       IF sy-subrc EQ 0.
         READ TABLE lt_retvalues INTO ls_retvalue
                                 WITH KEY fieldname = 'CHARG'.
         IF sy-subrc EQ 0.
           lips-charg = ls_retvalue-fieldval.
           gs_lips-charg = ls_retvalue-fieldval.
         ENDIF.
       ENDIF.
    Regards
    Reddy

  • Shipment header - Container ID field to list with the data from PM master

    Hi Gurus,
    In Shipment function (VT01N), Vehicle number is added manually in the field Container ID (VTTK-SIGNI) of Overview screen under processing tab.  The requirement is vehicle number should be picked up from the list of possible entries with PM Vehicle master data. (IE01)
    The discussion has been done with PM consultant and understood that it cannot be done by SPRO settings. Also the other technical possibilities have been checked for doing the same and proposed for ABAP enhancements.
    Is it technically possible with
    1) Search help Exit
    2) Screen Exit
    3) User Exit/other enhancements like BADI/BAPI
    Please help me in this regards.
    Regards,
    Anbu

    Check out GUIXT at www.synactive.com.  The base version is already free with SAPgui.  GUIxt allows you to do this without any ABAP coding (..almost any ABAP coding because their "local help" is handled by a supplied ABAP program.

  • Container ID field to list with the data from master in shipment header

    Hi,
    While do the Shipment VT01N, Vehicle number (ZZ05XX1588) is added manually in the field of Container ID in Shipment.
    The requirement is vehicle number should be picked up from the list of possible entries with Vehicle master data. (IE01)
    If is it possible, Please give to me details of the configuration steps and user Exit/other enhancements like BADI/BAPI.
    Please help me in this regards.
    Devendra

    Hi Devendra,
    You may get this functionality in DSD module. In standard LE-TRA its difficult to bring it from IE01.

  • Emails from another list are automatically deferred from Mailing list

    I have several mailing lists setup on on a server. Most emails go through the listhost without any problems. Posts should be configured to automatically go through for all posters.
    Some of these mailing lists are part of other mailing lists. If one sends an email to a mailing list, of which the server's mailing list is a member, the email will be deferred. The reason cited for deferring the email is "message has implicit destination." I have tried adding the original posters to automatically post all messages from this poster but that does not fix the problem.
    I would prefer not to have any delays or waits for approval of such messages. How does one change this setting?
    Thanks!
    Julia

    Hi ,
    Check the city LOV with hardcoded value first.
    Ex : select city_name from cities where country_name = 'India';
    Go with below query
    select city_name from cities where country_name = ':P_COUNTRY';
    Also select refersh on other parameter selection in the parameter.
    Thanks,
    Ananth

  • Get Managed Metadata (Taxonomy) ALL Lists with Columns and ALL Choice Lists with Columns VALUES programmatically

    Hi there,
    How to get Managed Metadata Lists  ALL Columns and ALL Choice Lists Columns that are used in the Site Collection programmatically please.
    Regards

    Hi sharepointaju,
    Managed Metadata list is a hidden list, that you can access it through
    http://siteurl/Lists/TaxonomyHiddenList/AllItems.aspx, then it is similar to other lists, you can use server or client code to interate each field in the list, show the the value for each item.
    For all choice list columns, I'm not clear what you mean in this situation, do you mean to get all choice columns in the site collection, if so, iterate site columns, and lists to get list fields, check whether it is a choice type field.
    This may be not your requirement, please provide more information how you want to get which value.
    Thanks,
    Qiao Wei
    TechNet Community Support

  • How to create dashboard through CSOM to show workflow from external lists

    We have following requirement.
    SharePoint 2013 standard edition environment is installed. SO no BI site template is possible.
    Development has to be through CSOM only.
    Vendor data is stored in external database in SQL server 2012.
    There are number of workflow running for external lists.
    Now the question is how can we create a dashboard through CSOM to show status of various workflows? How to develop through CSOM?
    Thanks in advance for help.

    Hello ,
    You can use below libraries for creating charts in sharepoint 2013 . 
    https://github.com/CardinalNow/ChartsInSharePoint2013
    or 
    http://modeln.github.io/sDashboard/
    ex. http://msdn.microsoft.com/en-us/library/office/dn481315(v=office.15).aspx
    I have used sDashboard This is really good . 
    Best
    Regards Kuldeep Verma
    Please remember to click "Mark As Answer" if a post solves your
    problem or "Vote As Helpful" if it was useful.  
    here requirement is totally different as CSOM and ext database, workflow and dash board together. actual answer is different.

  • PowerPivot refresh error with data feed from sharepoint list with empty exception information

    Hi,
    My Powpivot refreshing error seems to be different from what others already experienced.
    Scenario:
    Constructed an external data source in the format of Http://<server_IP>/sites/<mysitecollection>/_vti_bin/listdata.svc
    selected one table with some of the needed columns in the next step
    Create calculate colums etc.
    Create pivot tables etc.
    All worked well offline
    Upload the workbook into PowerPivot Gallery
    Reference it from a page through Excel Web Service webpart allowing manual refresh
    The refresh always reports failure with the named external data source
    I opend the log file in C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\LOGS and located the following error messages:
    ASPPHOST::ShowEngineError: Out of line object 'DataSource', referring to ID(s) 'f8939b694cae', has been specified but has not been used。The following exception occurred while the managed IDbCommand interface was being used: .
    Please note in the above message, NO detailed exception message was given. In other words,
    the exception information is empty.
    I checked as many things as I possibly could includin the security accounts etc. All seem to be right. But this empty exception got me stuck here.
    What could possibly go wrong? Any help will be appreciated.
    Thanks.

    Hello,
    Here is a good article regarding Where to get information about data refresh failures for your reference, please see:
    http://social.technet.microsoft.com/wiki/contents/articles/3870.troubleshooting-powerpivot-data-refresh.aspx
    In addition, which credential option you're configured for the PowerPivot data refresh in SharePoint farm? You can go through the following articles regarding configure the PowerPivot data refresh:
    Configure the PowerPivot Unattended Data Refresh Account (PowerPivot for SharePoint):
    http://technet.microsoft.com/en-us/library/ff773327.aspx
    Configure Stored Credentials for PowerPivot Data Refresh (PowerPivot for SharePoint):
    http://technet.microsoft.com/en-us/library/ee210671.aspx
    Hope this helps.
    Regards,
    Elvis Long
    TechNet Community Support

Maybe you are looking for

  • My Safari browser won't open. I had upgraded to Mac OS X Lion. What do I  do?

    My iMac is 2008 built. In March 2012, I upgraded to Mac OS X Lion. Since then I had problems after problems. Since the computer was getting slower and slower, I thought the Prosoft Drive Genious 3 would be useful. When I installed it on iMac, it caus

  • Compatibility with PowerPoint?

    I have edited videos in PE9 for Mac and saved them as both MOV and MPG files. Both formats play in VLC, and as expected, only the MOV plays in QuickTime. However, when I try to insert either format into PowerPoint (ver 2011 for Mac), an error message

  • Using GarageBand 3.0.4

    I was just wondering if Garage Band 3.0.4 has the capability of creating ringtones for the iPhone? I searched the garage band forum and couldn't find an answer. Thanks, Wes

  • Mail are make my Mac freeze when Re-indexing

    Hi Guys, After upgrade to Mavericks, I realize that my Mail is not indexing well. Sometimes I search email, and cannot found. After browsing, I see in the Apple Websites here : http://support.apple.com/kb/PH14876 That the Mail should be re-indexing.

  • Need help with Adobe Premiere Elements 2

    I can drag a large high rez jpeg into timeline. Then when I click to playback....it gets more pixelated. That's a bad beginning. Then, when I go to export it, I've tried several extensions. All look bad during playback on YouTube. This should be pret