Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Printing Foreign Key Value

Hi,
I have a gird that has ProductId (Shows Product Name), I've created a BusinessRule to print the selected row into a text file. How can I print the Product Name instead of ProductId?
When I edit the business rule in visual studio, it creates a function (C#) with all possible parameters from the grid including ProductId.

anyway around it? Thanks
1 person has
this question
+1
Reply
  • In the business rule, you can get to the product name as instance.productname
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • The local instance doesn't have ProductName, it only has ProductId.

    its like you have a Supplier & Product controllers, the supplier controller has only reference to ProductId and it doesn't have access to ProductName.

    In my grid, I am displaying all of my fields from the supplier controller and showing the ProductName instead of the ProductId but the BusinessRule doesn't seem to know about the ProductName...

    I could be doing something wrong?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Got it. I'm going to assume Products has a SupplierID field that establishes the relationship between the two. Forgive me if I have it backward, but you'll be able to figure it out even if I have it wrong.

    Go to Models, open Products. Add the Suppliers table to the view. Drag a relationship between SupplierID (on the Suppliers table) and SupplierID on the Products table. You should see a link between the two. You can now click the ProductName field on Products.

    Save, generate. Go to Design and open the suppliers controller. You should now see the ProductName field as ProductsProductName. You can now use this any way you want, i.e. instance. ProductsProductName.

    This should get you pretty close, let me know if you get stuck.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • I am using COT version 8.5.5.0 and it doesn't have model builder in it, it might be the newer versions but in my database I've step up the PK & FK relationship properly and the productName does show up in my grid as it should, look picture#1

    I am trying to save each row when highlighted into a text file "as-is", so I created a BusinessRule for my page. The BusinessRule tends to create a function with its parameters from this particular page, so for example the function looks like the following:

    public partial class BatchScheduleBusinessRules : demo.Data.BusinessRules
    {

    ///
    /// Rule "PrintToFileBusinessRule" implementation:
    /// This method will execute in the view with id matching "grid1" for an action
    /// with a command name that matches "Custom" and argument that matches "PrintRecord".
    ///
    [Rule("r100")]
    public void r100Implementation(string processOrder, string productId, double? batchPlanned, int? productionLaneId,.....etc

    If you notice, it brings only ProductId and I am trying to get a productName so I can save it via my StreamWriter

    Thanks again
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Ok, I had to modify the auto generated Command to include the Product.ProductName field, then creating a new field.

    re-creating the BusinessRule, it brought over the ProductName parameter.

    Dirty but it works. Thanks for your support
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated