Getting Opportunity ID in a Secondary Entity linked via Advanced Search Select

I have a Secondary Entity that is linked to the Opportunity Primary Entity via an Advanced Search Select field. When reporting on the Secondary Entity the data that is pulled into linked field is text, but what I actually need is the Opportunity ID. How do I go about getting this?

Thanks.

  • 0

    Thanks Jeff. I think that's getting at the issue I'm having, but it's quite enough to help me do what I want to do (I'm very much a novice at Sage CRM unfortunately).

    Should I edit the Opportunity entity to include an alias of the Opportunity ID?

  • 0

    On further experimentation this is possible. Sage CRM seems to make it bizarrely difficult for reports to contain IDs. Seems to go against generally agreed database best practices...

    In any case, for your secondary entity, create view that left joins the primary entity. And then specifically select the ID of the primary entity with an alias. For example the view would be:

    CREATE VIEW myView

    AS

    SELECT *, PrimaryEntity.primaryentityid AS thisIsMyAlias

    FROM SecondaryEntity

    LEFT JOIN PrimaryEntity

    ON SecondaryEntity.primaryentityid = PrimaryEntity.primaryentityid

    Make sure this view has Reports View, Groups View and SData View ticked (depending on how you're planning to use it)

    What's really interesting about this is that when I run a report on the SecondaryEntity without any joins, the primaryentityid comes through as the PrimaryEntity description, not the ID. But the join seems to work on the underlying IDs. I'm guessing this is because entities in Sage CRM are not tables, and hence they're abstracting to make things easier for the user (or in this case vastly and unnecessarily more difficult)