I am having a small issue with a MR script I have ...
# suitescript
d
I am having a small issue with a MR script I have written, it is not performing as expected by running subsequent scripts on the inventory item as expected. The script updates a price field which is the basis for calculating all other price levels. However none of the other price basis are update after the script is run, only the the price field that is directly updated. I have loaded the item with the dynamic option true and my expectations would be that the secondary script responsible for updating the other price fields would be executed.
b
how are the script deployments of the other scripts setup?
d
I believe its a NS native script that updates the price fields
My guess is its a client side script
b
you should have no expectation that a client script runs for a server script
d
Sorry if I was mistaken but I thought loading a record with dynamic would trigger CS scripts. I guess I was mistaken
I guess my resolution would be to try to load each of the price levels and execute the logic in myscript. Is there a way to load a accounting list?
b
a lot of what you are saying doesnt sound fully correct
usually you can find the script that you are trying to trigger
so either you havent looked very far, or its not a script you are trying to trigger
d
I am not a super experience SS developer, so please be patient.
What I know is that when I edit the price basis field on the client that the other levels update accordingly.
I am assuming it is a client side script based on that
since from what you have said it is not possible to trigger this action from my SS script. I figured my resolution was to load the configurations for each price level retrieve the discount/markup settings and calculate each of those values and set them.
But I am not even sure its possible to do it, since I have little idea on how to load something from “Accounting Lists”
b
it sounds like you are trying to update the pricing matrix
and have changes made to the base price affect other price levels which have a markup percentage
thats not functionality from a script, its a native feature
d
thats exactly what I am trying to do
b
that should trigger from a change to the pricing matrix
d
but yet here I am 🙂
b
what does your map/reduce look like
d
OK to DM it to you? It relies on a library I have written and would be a lot to post all the functions
b
fair chance that is too much for what you are trying to do
d
the library has been built up to support other scripts
b
make your map function simple, load the item record, set the matrix sublist value, then save the record
get that working then move onto a library
d
Most (cough) of the code in the library works
It was built from refactoring other scripts and there to reduce redundancy of the same code over and over again.
take a look its in your DM
b
its not too much code, but its not code that I would run in my test account
im recommending you to make your code only try setting the pricing matrix field
d
Probably don’t need to……. I think I just found my donkey mistake
b
so that you can more easily make changes
d
Copy code
function updateItemPriceLevelPrice(item, price, pricelevel_id) {
    var sublist = "price";
    var field = "price";
    var line = item.findSublistLineWithValue({sublistId: sublist, fieldId: "pricelevel", value: pricelevel_id});
    if(line >= 0 && price >= 0) {
      item.selectLine({sublistId: sublist, line: line});
      item.setCurrentMatrixSublistValue({
            sublistId: sublist,
            fieldId: field,
            column: 0,
            value: price,
            ignoreFieldChange: true,
            fireSlavingSync: true
      });
      item.commitLine({sublistId: sublist});
      return true;
    }
    return false;
  }
☝️ my guess is my issue is that ignoreFieldChange
@battk thank you for helping me find my idiocy 🙂