infor-cloud / m3-h5-sdk

https://infor-cloud.github.io/m3-h5-sdk/
34 stars 20 forks source link

How to make a simple "search engine" to retreive products ? #123

Closed Messaoudi-Nagib closed 2 years ago

Messaoudi-Nagib commented 2 years ago

Description

Hi, I'm working on a mashup wich allows users to search for a specific product and then get basic information about it. They can search by ITNO, designation (ITDS), gencod and so on. I want to make the search really simple to the users, but this leads me to an issue. Based on the way the user want to search, I'm using either API calls or panels. Panels are giving me very strange results, and I can't figure out how they really work. Sometimes, I can make them work and sometimes they give me results that doesn't match at all what I've asked for.

Anyone can explain how do panels work please ? I would like to know how I can do a simple "search engine" based on what the user had filled into the input field.

Thank you.

Versions

Infor M3 cloud (SaaS)

swuendri commented 2 years ago

Hi @Messaoudi-Nagib,

maybe I'm wrong but mashups and m3-h5-sdk are different things, so it's not possible to solve your question here.

Messaoudi-Nagib commented 2 years ago

Oh sorry I thought I was on mashup's github, my bad

swuendri commented 2 years ago

No problem @Messaoudi-Nagib, but close the issue please.

Messaoudi-Nagib commented 2 years ago

Hi, after thinking about it, I think this is the right place to solve my issue, I use the term mashup but I was talking to m3-h5-sdk since I use odin and all the infor-m3 tools in angular. So do you guys have any advices on how to do it the right way ? I use angular and odin with m3 APIs/panels for now.

Thank you, regards

swuendri commented 2 years ago

Hi @Messaoudi-Nagib, welcome back. Can you provide some code snippets of using panels? Currently I'm more familiar using APIs within own M3 H5 applications.

Messaoudi-Nagib commented 2 years ago

Hi @swuendri , here's my code snippet of how I use panels :

   getClientData(nCodeClient){
      if(nCodeClient != ''){
         /* Here's my panel request */
         var request = {
            program: 'CRS610',
            query: nCodeClient,
            sortingOrder: '01',
            view: 'STD01-01',
            startPanelFields: { 'WFSLTC': '', 'WTSLTC': '', 'W1OBKV': nCodeClient, 'W2OBKV': nCodeClient },
         } as ISearchRequest;
      }

      /* Then I use formService */
      this.formService.executeSearch(request).subscribe((r) => {
         if (r.result !== 0) {
            return;
         }
         let results = [];
         const panel = r.panel;
         if (panel) {
            const list = panel.list;
            if (list) {
               results = list.items;
               this.aListeClient = results;
               this.updateGridData(this.dataGridClient, this.aListeClient);
            }
         }
      });
   }

Panels are returning some weird results sometimes, even if I fill the startPanelFields property... Thank you for helping me,

Regards

swuendri commented 2 years ago

Thank you @Messaoudi-Nagib for the code snippet. I also found the usage of MMS001 search in m3-odin-sample application and I think I understand this kind of search.

So let's have a look at your first question and what's the problem to solve? Please give me an advice in which area you need help:

  1. building the search query itself or
  2. why there are different search results between using M3 program directly or Odin FormService or
  3. are you looking for alternative ION API calls?

Or maybe I didn't get your point and you have to add option 4 😄.

Messaoudi-Nagib commented 2 years ago

Hello @swuendri, the main problem I'm trying to solve is :

I want to give to users a simple UI, with only a searchbar and a radio button for choosing what "key" they want to use for searching items ( for instance ITNO, EAN code, name of the item etc...), just like that : image

I've tried to use APIs but there is one thing that bother me, APIs are good if the exact result is asked, if not, they don't send you data back. That's why I came across using panels, because even if you enters an incomplete request like an incomplete ITNO code, panels still send you results that might correspond.

The advice I will chose from your reply is :

why there are different search results between using M3 program directly or Odin FormService

I would like to know if you have ever used panels, and if so, can you help me to use them ? Is it a good way to use them as long as they do not have any sort of documentation ?

I hope you'll understand what I want to build !

Thank you very much, regards

swuendri commented 2 years ago

Hello @Messaoudi-Nagib, I think that I understand your case because I have a similar use case in current project. In my opinion the most import thing is to understand the search queries Infor Docs. I had to read this several times and tried searches again and again. It's a very powerful search engine but not easy to understand.

With knowledge about the search queries you should be able to search by different keys manually. So the next step is to translate this in code. I prefer using a API because I can check my application locally. Using the FormService it would be necessary to deploy application each time after some changes. This isn't really convenient. But the result will be the same because the way you use doesn't matter.

Messaoudi-Nagib commented 2 years ago

Ok, I will check search queries then ! I hope this is going to work 😃 Thank you very much for taking the time to answer my questions and giving me advices. Best regards !