List of Value Pairs in Scripted Business Object
I have scripted business object with the following interfaces:
IDataSetAccess, IPagedAccess, IIndexedAccess, ISupportRefill
This scripted business object calls a web service and creates a table with two columns.
I would like to use the values in those columns as a list of Value-Pairs that I can use in some dropdown fields in my forms. I can set up this up in Designer (as per the screenshot below)
but when I try to deploy my solution I get the following error message:
Error 06/07/2012 19:01:42 SIMS 'Metastorm.Runtime.Models.LibLPLookAndFeel.bosGetCodePairFromLocalSource' does not contain a definition for 'GetColumns' and no extension method 'GetColumns' accepting a first argument of type 'Metastorm.Runtime.Models.LibLPLookAndFeel.bosGetCodePairFromLocalSource' could be found (are you missing a using directive or an assembly reference?) 3347 56
I have tried to make up a 'GetColumns' method to provide the contents thatnI want to expose as value pairs, but I am not successful. I have checked the Designer guide, this forum and Google and I have not found any references to this GetColumns method.
Any idea about how to resolve this problem?
Thanks in advance.
Comments
-
Hi Xavi
Looks like to use GetColumns you also need to implement IColumnAccess
However I recommend speaking to the helpdesk about this to confirm that it is just a documentation oversight and we do support using this interface from a scripted business object.
Thanks
iain
0 -
Where can found documentation about this IColumnAccess interface?
0 -
It is a great deal easier to use a function to return a name-vale pair list. Unless you specifically need the caching abilities of a scripted Business Object, I would recommend looking at a simple function.
0 -
Hi,
I am experiencing the same error on my scripted BO, which is populating a value-name pair dropdown.
Error 26/09/2013 4:19:16 PM RVProject 'Metastorm.Runtime.Models.EliteLibrary.qryEliteSiteAddress' does not contain a definition for 'GetColumns' and no extension method 'GetColumns' accepting a first argument of type 'Metastorm.Runtime.Models.EliteLibrary.qryEliteSiteAddress' could be found (are you missing a using directive or an assembly reference?) 7083 72
Has anyone found a solution for this error?
Thanks.
#region Using Statement using System; using System.Data; using System.Collections.Generic; using Metastorm.Ide.Extensibility; using Metastorm.Runtime.Core; using Metastorm.Runtime.Types; using System.ComponentModel; using Metastorm.Runtime.Contracts.Mbo; using Metastorm.Runtime.Core.Mbo; using System.Linq; #endregion Using Statement //Change this to a namespace that will suit you namespace Metastorm.Runtime.Models.EliteLibrary { /// <summary> /// This needs to be a class or an interface that will support public, static methods/properties /// </summary> public abstract class EliteBOSiteAddress : IDataSetAccess, ISupportRefill { private DataSet data = null; private MboConnection connection = null; private MboConnectionInfo connectioninfo = null; public EliteBOSiteAddress() { connection = new EngineMboConnection(); // Attach to the cache events CacheHelper.LoadFromCache += LoadDataFromCache; CacheHelper.SaveToCache += SaveDataToCache; // Retrieve any previously cached data LoadDataFromCache(this, EventArgs.Empty); } #region Parameters public abstract Metastorm.Runtime.Types.Text configId { get; } public abstract Metastorm.Runtime.Types.Text clientNumber { get; } #endregion #region IDataSetAccess Members public System.Data.DataSet Read() { if (data == null) { string query = "SELECT SiteIndex, AddressFull FROM SiteAddressIndexView inner join Client on ClientIndex=PMSEntityIndex where altnumber='"+clientNumber+"'"; string confId = configId; if(confId.IndexOf("PROD")>0) data = Mstm.SelectSql(new MDD_PROD(), query, null).GetDataSet(); else data = Mstm.SelectSql(new MDD_DEV(), query, null).GetDataSet(); //data.Tables[0].PrimaryKey = new DataColumn[] {data.Tables[0].Columns["CCE_Key"]}; data.AcceptChanges(); } return data; } public void Write(System.Data.DataSet dataSet) { if (dataSet.HasChanges()) data.Merge(dataSet.GetChanges()); } #endregion #region IEditableAccess Members public virtual bool ReadOnly { get { return false; } } public void Commit() { if (data.HasChanges()) { DataSet cambios = null; cambios=data.GetChanges(); this.connection.Update(cambios); } } #endregion #region Variables public virtual Metastorm.Runtime.Types.Text AddressFull { get { return GetField<string>("AddressFull"); } set { SetField<string>("AddressFull", value); } } public virtual Metastorm.Runtime.Types.Text SiteIndex { get { return GetField<string>("SiteIndex"); } set { SetField<string>("SiteIndex", value); } } #endregion #region ISupportRefill Members public virtual bool AlwaysRefresh { get { return false; } } #endregion #region Helper methods private T GetField<T>(string fieldName) { if (data == null) this.Read(); if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0) return (T)data.Tables[0].Rows[0][fieldName]; else return default(T); } private void SetField<T>(string fieldName, T value) { if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0) data.Tables[0].Rows[0][fieldName] = value; } #endregion #region Caching events private void SaveDataToCache(object sender, EventArgs e) { if (data != null) CacheHelper.GetCachedMboState(this).Data = data; } private void LoadDataFromCache(object sender, EventArgs e) { data = CacheHelper.GetCachedMboState(this).Data; } #endregion } }
0 -
Adding the below methods to the scripted business object resolves the above issue. One that takes a column name and returns a list to bind to dropdown. Other returns a key value pair. //This method helps in returning a key value pair for the dropdown based on passed inputs public KeyValuePair<KeyT, ValueT>[] GetColumns<KeyT, ValueT>(string keyColumnName, string valueColumnName) { if (data == null) this.Read(); if(data.Tables.Count == 0) return new KeyValuePair<KeyT, ValueT>[0]; List<KeyValuePair<KeyT, ValueT>> result = new List<KeyValuePair<KeyT, ValueT>>(); DataTable table = data.Tables[0]; DataColumn keyColumn = table.Columns[keyColumnName]; DataColumn valueColumn = table.Columns[valueColumnName]; foreach (DataRow row in table.Rows) result.Add(new KeyValuePair<KeyT, ValueT>( ConvertDBValue<KeyT>(row[keyColumn]), ConvertDBValue<ValueT>(row[valueColumn]))); return result.ToArray(); } private T ConvertDBValue<T>(object value) { if (value is DBNull) return ValueHelper.TryGetValue<T>(null); return ValueHelper.TryGetValue<T>(value); } //The method helps in returning a key value pair for the dropdown based on passed inputs public List GetColumns(string columnName) { if (data == null) this.Read(); if(data.Tables.Count == 0) return null; List ddllist = new List(); if(data.Tables.Count > 0) { ddllist = data.Tables[0].GetFields<string>(columnName).ToArray(); } return ddllist; }
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 153 General Questions
- 148 Thrust Services
- 57 Developer Hackathon
- 37 Thrust Studio
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 188 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories