How to trigger bot based on value on other table?

Hi guys, is there any way to trigger bot when column value is updated in other table? I want to trigger my bot only when I update "Status" column from "Menunggu Persetujuan" to "Disetujui" and not trigger when the "Status" value is "Ditolak". Here's the tables that I'm working with:

Table "Barang Keluar"

agnispremz_2-1702264419595.png

Table "List Barang Keluar"

agnispremz_1-1702264373910.png

 

 

Solved Solved
0 4 280
1 ACCEPTED SOLUTION

Finally found solution for my issue. Here's the step:
1. Make a automation to change value in column "Status" whenever any update occurs. The condition for this automation is [_THISROW_BEFORE].[Status]<>[_THISROW_AFTER].[Status] and body for webhook is like this:

{
"Action": "Edit",
"Properties": {
"Locale": "en-US",
"Location": "47.623098, -122.330184",
"Timezone": "Pacific Standard Time"
},
"Rows": [
<<START: FILTER(List Barang Keluar, ([_THISROW].[ID]=[ID]))>>
{
"ID Barang": "<<[ID Barang]>>",
"Status": "<<ANY(SELECT(Barang Keluar[Status], [_THISROW].[ID]=[ID]))>>"
}
<<End>>
]
}

2. After that, make another automation for subtract stock from List Barang when the "Status" value in Barang Keluar change to "Disetujui":

Condition: AND([_THISROW_AFTER].[Status]="Disetujui", [_THISROW_BEFORE].[Status]<>[_THISROW_AFTER].[Status])

Body: {
"Action": "Edit",
"Properties": {
"Locale": "en-US",
"Location": "47.623098, -122.330184",
"Timezone": "Pacific Standard Time"
},
"Rows": [
{
"ID Barang": "<<FILTER("List Barang", ([_THISROW].[Nama Barang]=[Nama Barang]))>>",
"Stok Barang": "<<ANY(SELECT(List Barang[Stok Barang], [_THISROW].[Nama Barang]=[Nama Barang]))-[_THISROW].[Jumlah]>>"
}
]
}

View solution in original post

4 REPLIES 4

Hi,

Test

AND([_THISROW_AFTER].[Status] = "Disetujui", [_THISROW_BEFORE].[Status] <> [_THISROW_AFTER].[Status])

More info
Access column values before and after an update 


@jballester wrote:
AND([_THISROW_AFTER].[Status] = "Disetujui", [_THISROW_BEFORE].[Status] <> [_THISROW_AFTER].[Status])

 

May I ask where do I need to put this syntax? I put it in condition, but it won't run the task when [Status] is changed to "Disetujui". Is there anything I need to provide to help in resolving this issue?

I have found a workaround for my issue by adding new column named "Status" in List Barang Keluar and make a new bot to update value "Status" in List Barang Keluar whenever value "Status" in Barang Keluar is updated. But, now I face a new issue when adding more than 1 item the value "Status" in List Barang Keluar doesn't updated. This is my webhook body for the bot:

{
"Action": "Edit",
"Properties": {
"Locale": "en-US",
"Location": "47.623098, -122.330184",
"Timezone": "Pacific Standard Time"
},
"Rows": [
{
"ID Barang": "<<FILTER("List Barang Keluar", ([ID Penanggungjawab]=[ID]))>>",
"Status": "<<[Status]>>"
}
]
}

I got this error:

Failed: Webhook HTTP request failed with exception The remote server returned an error: (404) Not Found.

Finally found solution for my issue. Here's the step:
1. Make a automation to change value in column "Status" whenever any update occurs. The condition for this automation is [_THISROW_BEFORE].[Status]<>[_THISROW_AFTER].[Status] and body for webhook is like this:

{
"Action": "Edit",
"Properties": {
"Locale": "en-US",
"Location": "47.623098, -122.330184",
"Timezone": "Pacific Standard Time"
},
"Rows": [
<<START: FILTER(List Barang Keluar, ([_THISROW].[ID]=[ID]))>>
{
"ID Barang": "<<[ID Barang]>>",
"Status": "<<ANY(SELECT(Barang Keluar[Status], [_THISROW].[ID]=[ID]))>>"
}
<<End>>
]
}

2. After that, make another automation for subtract stock from List Barang when the "Status" value in Barang Keluar change to "Disetujui":

Condition: AND([_THISROW_AFTER].[Status]="Disetujui", [_THISROW_BEFORE].[Status]<>[_THISROW_AFTER].[Status])

Body: {
"Action": "Edit",
"Properties": {
"Locale": "en-US",
"Location": "47.623098, -122.330184",
"Timezone": "Pacific Standard Time"
},
"Rows": [
{
"ID Barang": "<<FILTER("List Barang", ([_THISROW].[Nama Barang]=[Nama Barang]))>>",
"Stok Barang": "<<ANY(SELECT(List Barang[Stok Barang], [_THISROW].[Nama Barang]=[Nama Barang]))-[_THISROW].[Jumlah]>>"
}
]
}

Top Labels in this Space