Question

I am having an issue populating a data table with the correct data.

I have a Data Table that I am using in a form. It is called userConfigProfiles. It has a 2 FK columns groupId(this joins to UserGroupInfo) and corpProfileId(this joins to a table I created). That data in userConfigProfiles is populated from another form and is currently populated appropriately.

The issue is, I need to create a drop down on the SalesTable form that shows a subset of the rows in userConfigProfiles based off of what UserGroups the current user is in.

I tried to do this by adding the below code to the table, userConfigProfiles in the SalesTable form:

public void init()
{
    userConfigProfiles.data(userConfigProfiles::find());

    super();
}

Then I added this find method to the Table itself:

static public userConfigProfiles find()
{
    userConfigProfiles userProfile;
    UserGroupList userGroupList;

    str 8 u = curUserId();

    select *
    from userProfile
    order by userProfile.bdcProfileId
        join userGroupList
    where userProfile.groupId == userGroupList.groupId
        && userGroupList.userId == u;

    return userProfile;
}

However, it appears that even though my find method is called and it returns the correct data it is not affecting the data that goes into the drop down list on my form.

My drop down list is a StringEdit field with a DataSource of userConfigProfiles and a DataField of corpProfileId.

I am pretty sure there are several ways to solve my problem and I am open to any of them, even if it means removing all of my code and doing the drop down box completely differently.

Was it helpful?

Solution

Create a query using table UserConfigProfiles with an exist join (property joinMode) to table UserGroupList, use the appropriate relation, then add a range on field UserId with a value of (currentUserId()).

This value is a dynamic query expression which is provided by the class SysQueryRangeUtil.

Finally create a lookup using class SysTableLookup using your query.

OTHER TIPS

By far the best tutorial on lookup methods is by Vanya:

http://kashperuk.blogspot.com/2009/04/lookup-methods-tutorial-custom-list.html

Download his tutorial XPO and use one of his options for your form. Your code looks a bit like a hack job.

If you're trying to display a subset of records on the table, you should modify the query(), but if you're trying to change the displayed values from a lookup, then I'd check out his blog post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top