- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 06:25 PM
Hello everybody,
I am trying to use now these three tables to perform the following calculations, only clarifying that already worked, but now, due to the fact that i made a many-to-many relationship and add that related list so now you must apply from that table calculations.
I'll explain a little better how it works:
The code makes the value of "u_estimacion_de_hrs", and bring it to the subtract with "u_hrs_disponibles_del_periodo" and put it in the variable "u_hrs_restantes".
this is the code:
When to run: After
Insert
Update
condition: estimación de Hrs changes.
This BR is located in the table of incidents
Here I have no problem.
--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
and now I have a new related list because I did a new relationship many to many, the idea of having this relation is because i need to have the same incident in different periods.
That relationship was not possible because only he could have an incident at a period.
The code should be the value of "u_estimacion_de_hrs", and bring it to the subtract with "u_hrs_disponibles_del_periodo" and put it in the variable "u_hrs_restantes".
Only that now the table is different, the fields that are relational in that list with the exception of the incident number were brought by dot walking.
Could you help me with the BR to work now with this new table, thank you for your help.
Regards,
CC
dvp, I appeal to you, you always have a good answer for this type of unknowns.
I appreciate your help.
thanks for advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 02:16 AM
Hello Christian,
Write a business rule on m2m table with the below script
In this script you need to update the field name on mem table
var prj = new GlideRecord('u_periodo_de_servicio');
prj.addQuery('sys_id', current.YOUR_PERIOD_FIELD_NAME_in_M2M table);
prj.query();while(prj.next()){
var rp = new GlideRecord('incident');
rp.addQuery('u_periodo', current.YOUR_PERIOD_FIELD_NAME_in_M2M table);
rp.query();
var count = 0;
while(rp.next()){
count += rp.u_estimation_de_hrs
}prj.u_hrs_restantes = prj.u_hrs_disponibles_del_periodo - count;
prj.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 08:33 AM
hello dvp,
In response to your questions:
the BR is located in table "u_m2m_incidents_periodo_de_s"
The INC 13727 and 13725 both are not related.
It is important to know that the table "u_m2m_incidents_periodo_de_s" has a many-to-many relationship, I created the table.
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 08:43 AM
So how are you relating incidents and contracts? Is it through reference field?
On incident table 'u_periodo' field is referenced to which table is it to contract or u_periodo_de_serviceo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 12:40 PM
Hello dvp,
The relationship between incident and contract is with the table "u_m2m_incidents_periodo_de_s".
This is seen in the incident:
When I select "new" in the table "u_m2m_incidents_periodo_de_s" in the incident form, the followings appears:
-----------------------------------------------------------------------------------------------------------------------------------------------------
On incident table 'u_periodo' field is referenced to which table is it to contract or u_periodo_de_serviceo
I was going through and I just found that the field "u_periodo" does not exist, the relationship between the incident and contract are the table "u_m2m_incidents_periodo_de_s" that has a many-to-many relationship.
Regards,
I hope you can help me.
thanks for advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:53 AM
it's important to mention:
the relationship of the contracts it is also the caller have the company and the company have a contract.
and the relationship between incident and contract is with the table "u_m2m_incidents_periodo_de_s".
I'm trying to solve it but still didn't know why it doesn't work.
could you help me.? Please.
thanks for advance.