This topic contains 1 reply, has 0 voices, and was last updated by alistairpaul 9 years ago.

  • Author
    Posts
  • #6987 Score: 0

    kingson513
    • Contributions: 0
    • Level 1

    Hi All,

    I have having a problem on getting the internalID of the Item from the item search result.

    I am using the Item Search Row and Item Search Row Basic logic to get.

    The Item Search Row Basic have a field which is internalId, but i would never get the real internal ID for the Item.

    is there anyway to get the internal id of the item from the item search?

    here is the code i tried to get the internal id, but failed. (in C#)

    PHP Code:

     foreach (SearchRow row in rows)
                        {
                            // Cast the search row to a transaction search row and grab the basic row info
                            ItemSearchRow tsr = (ItemSearchRow)row;
                            ItemSearchRowBasic tsrb = tsr.basic;
                            string itemName = (tsrb.itemId != null) ? tsrb.itemId[0].searchValue : ” “;
                            SearchColumnSelectField[] itemInternalID = tsrb.internalId;
                            RecordRef item_ = itemInternalID[0].searchValue;
                            string itemIntID = “”;
                            _out.writeLn(”     itemInternalID:       ” + itemIntID);

                            RecordRef item1 = new RecordRef();
                            item1.internalId = “101026”;
                            item1.type = RecordType.inventoryItem;
                            item1.typeSpecified = true;
                            RecordRef[] recordrefs = new RecordRef[1];
                            recordrefs[0] = item1;

                            ItemAvailabilityFilter filter = new ItemAvailabilityFilter();
                            filter.item = recordrefs;
                            GetItemAvailabilityResult res = _service.getItemAvailability(filter);
    //code not finished

    Best Regard,

    Kingson
    This is a cached copy. Click here to see the original post.

  • #6988 Score: 0

    alistairpaul
    • Contributions: 0
    • Level 1

    This works for me, to see the internalId of my Service Items, which I assume you could switch out for whatever object type your target Item is.

    Basically issue a search, then loop the search result pages and process each page’s results, and that’s where you apply the object type casting and obtain any item info you want, including the internalId.

    Code:
    public void getAllItems(Logger _out)
    {
    ItemSearchBasic itmSearchBasic = new ItemSearchBasic();
    SearchResult itmSearchResult = _service.search(itmSearchBasic);
    if (itmSearchResult.status.isSuccess)
    {
    _out.writeLn(“Found # records: ” + itmSearchResult.totalRecords.ToString());
    _out.writeLn(“Total Pages: ” + itmSearchResult.totalPages.ToString());
    if (itmSearchResult.totalRecords > 0)
    {
    for (int p = 1; p <= itmSearchResult.totalPages; p++)
    {
    processItemSearchResult(itmSearchResult, _out);
    if (itmSearchResult.pageIndex < itmSearchResult.totalPages)
    {
    itmSearchResult = _service.searchMoreWithId(itmSearchResult.searchId, p + 1);
    }
    }
    }
    }
    else
    {
    _out.writeLn("Error Searching Items : " + getStatusDetails(itmSearchResult.status));
    }
    }

    public void processItemSearchResult(SearchResult response, Logger _out)
    {
    Record[] records = response.recordList;
    ServiceSaleItem item = new ServiceSaleItem();

    for (int i = 0; i < records.Length; i++)
    {
    item = (ServiceSaleItem) records[i];
    _out.writeLn("internalId: " + item.internalId + ", displayName: " + item.displayName);
    }
    }

You must be logged in to reply to this topic.