Forum Discussion

kwojsz's avatar
kwojsz
New Contributor III
3 years ago

MemberScript vs DataCellPk

Hi,

Is there an easy way to get MemberScript from the DataCellPk? I can see a method called 'GetMemberScript' (what a surprise) on DataCellPk object, but it doesn't work (or I cannot figure out how it works) in Extensibility Rule. The goal is to take the details of one DataCell, replace one of the members and process (validate) such created reference to another DataCell. Any tips?

Best,

Karol

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    You really don't need the memberscript to play around with members.

    Best practice is to take yourDataCell.DataCellPk and look up the relevant IDs (.FlowId, .EntityId, etc); assigning different IDs will attach different members to the cell. Working with IDs is the fastest and recommended method.

    If you really want to use names, you can use the various yourDataCell.GetEntityName(api) methods, but only to look up currently attached members. To manipulate them, you'll still need to use DataCellPk and IDs.

  • kwojsz's avatar
    kwojsz
    New Contributor III

    Thanks for the tip, I thought these Id's are Read Only properties. Anyway, any idea why after replacing MemberId, the value of the cell is still the value of the original cell? Generally, in this exercise I'm trying to verify whether the inputted value has comment provided in the one of the Annotation views (this is what I'm replacing in the original DataCell coordinates). Am I missing something? Is there an easier way to do this?

    • JackLacava's avatar
      JackLacava
      Honored Contributor

      When you first create or retrieve a DataCell object, you're loading it into memory. Modifying the member IDs will not modify the value of the cell, just where the cell will be stored once you eventually save it back to the database (either directly with api.Data.SetDataCell, or adding it to a DataBuffer and then saving that buffer with api.Data.SetDataBuffer).

      If your IDs appear readonly, just create a brand new DataCell object passing the old one as parameter, e.g. dim newCell as DataCell = new DataCell(oldCell). That one will be editable. In your case, I think what you want to do is change the view ID, then use api.Data.GetDataCell(yourCellPKwithModifiedID) to retrieve the actual cell you want values for.

      • kwojsz's avatar
        kwojsz
        New Contributor III

        Thanks for clarifying this! I needed this for my SaveDataEventHandler logic and in my case it appeared there are some blockers for taking this approach (no access to content of other than the processed NewDataCell, unless I'm wrong...). Anyway, good lesson how to deal with DataCells!