Copy subtask fields to parent Question

0
Question posted 3/18/10 by Deffy Mub
Details:

Is there a way to copy field values within a subtask and paste it into a parent. I have a mashup (SBM 2009 R1) parent that has a subtask that generates IDs. I want to be able to auto grab the results generated and copy them to field values within my parent form. is this even possible through scripting?
Responses (7)
  • Accepted Answer

    Thursday, January 27 2011, 01:35 PM - #Permalink
    0
    Comment posted 3/19/10 by Clyde Vasey

    For th emost part, if you can think of it, you can program it. This type of scripting is pretty standard once you get a good understanding of scripting and especially teamscript. I have been coding in teamscript since 2004 and attending the Serena teamscript course. You might consider taking the course to get a sound background on the capabilities of teamscripting. There is a lot of power in the language and Mashups.
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, January 27 2011, 01:35 PM - #Permalink
    0
    Comment posted 3/19/10 by Deffy Mub

    Yes I am in the process of taking additional course but was trying to use the resources in the commjunity to see if there are samples of helpful scripts that can help me get a start with using subtasks.
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, January 27 2011, 01:35 PM - #Permalink
    0
    Comment posted 3/22/10 by Oliver Kraus

    Hi
    Once you have both records (parent and subtask) as objects in Mashup Script, the copy operation is quite simple:
    Call subrec.GetFieldValue(..., val)
    Call parent.SetFieldValue(..., val)
    It is more effort to get the parent item itself. I have a function in my library. It will return the parent (of a subtask relation) for the provided item (which could be Shell.Item).
    ' return the first parent item of the subtask
    ' returnd value can be Nothing, so "Nothing" should be handled.
    ' Example
    ' Set parent = getSubtaskParent(item)
    ' If (parent Is Nothing) Then
    '
    Function getSubtaskParent(item)
    Dim parent
    Dim masteritemid
    Dim mastertableid
    Dim subitemid
    Dim subtableid
    Dim wc
    Dim subtaskRec
    Set parent = Nothing

    ' get Child Item Id
    subitemid = item.GetId()
    ' get CHild Table Id
    subtableid = item.GetRecTableId()

    wc = ""
    wc = wc & "TS_SUBITEMID = " & subitemid
    wc = wc & " and TS_SUBTABLEID = " & subtableid

    Set subtaskRec = Ext.CreateAppRecord(Ext.TableID("TS_SUBTASKS"))

    If subtaskRec.ReadWithWhere(wc) Then
    ' get Master Item Id
    Call subtaskRec.GetFieldValue("MASTERITEMID", masteritemid)

    ' get Master Table Id
    Call subtaskRec.GetFieldValue("MASTERTABLEID", mastertableid)

    ' create object item for the parent

    Set parent = Ext.CreateAppRecord(mastertableid)
    Call parent.Read(masteritemid)

    End If ' getSubtaskParent 2
    Set getSubtaskParent = parent
    End Function
    Oliver
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, January 27 2011, 01:35 PM - #Permalink
    0
    Comment posted 4/27/10 by Deffy Mub

    Thank you for your help.
    I am trying to figure out where I need to start. In my Parent item I have a field called CI Number and in my subtask I have the field called "CI Number Generated". All I want to do is to copy the value from the CI Number Generated" and paste it into the CI Number field.
    With the code you gave me, do I just paste and modify it in the script portion of composer?
    The reply is currently minimized Show
  • Accepted Answer

    Marianne
    Marianne
    Offline
    Thursday, August 02 2012, 11:28 PM - #Permalink
    0
    Hi,

    In first thank for this script it's very help full.

    But I have a problem with it. The script not write in my parent field. he get field information, like title, commentary field....

    Regards,

    Marianne
    The reply is currently minimized Show
  • Accepted Answer

    Marianne
    Marianne
    Offline
    Friday, August 03 2012, 02:32 AM - #Permalink
    0
    Hi have found my problem, Idon't do an update...
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 06 2017, 10:43 AM - #Permalink
    0
    Hi, I have tried about a thousand variations of this script and I can't get it to function. I have tried moving the variables to be global and still nothing. Further more, when I try to debug inside of the function, it doesn't give me any errors, but it also doesn't log any info. If I run the same debug outside of the function I get the info I would expect in the log. I have the debug section commented out below because it wasn't doing anything.

    Here is where I am at right now. Any help would be appreciated.

    Dim parent
    Dim masteritemid
    Dim mastertableid
    Dim subitemid
    Dim subtableid
    Dim wc
    Dim subtaskRec
    Dim val

    Call shell.item.GetFieldValue("VENDOR", val)

    Function getSubtaskParent(item)

    Set parent = Nothing
    Set CurrentRecord = Shell.item

    ' get Child Item Id
    subitemid = item.GetId()
    ' get CHild Table Id
    subtableid = item.GetRecTableId()

    wc = ""
    wc = wc & "TS_SUBITEMID = " & subitemid
    wc = wc & " and TS_SUBTABLEID = " & subtableid


    Set subtaskRec = Ext.CreateAppRecord(Ext.TableID("TS_SUBTASKS"))

    If subtaskRec.ReadWithWhere(wc) Then
    ' get Master Item Id
    Call subtaskRec.GetFieldValue("MASTERITEMID", masteritemid)

    ' get Master Table Id
    Call subtaskRec.GetFieldValue("MASTERTABLEID", mastertableid)

    ' create object item for the parent

    Set parent = Ext.CreateAppRecord(mastertableid)
    Call parent.Read(masteritemid)

    End If ' getSubtaskParent 2
    Set getSubtaskParent = parent

    Call parent.SetFieldValue("VENDOR", val)

    'Call parent.GetFieldValue("VENDOR", val)

    'if val = "" then

    'Call Ext.LogErrorMsg( "Unable to find value")

    'else

    'Call Ext.LogErrorMsg( "value = " &val)

    'end if



    End Function
    The reply is currently minimized Show
Your Reply

Recent Tweets

Twitter response: "Invalid or expired token."